} else {
servePath = strings.TrimSuffix(servePath, ".html")
}
- handler = page.Static(fpath)
+ p := page.Static(fpath)
+ if p.Error() != nil {
+ return p.Error()
+ }
+ handler = p
default:
handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
f, err := os.Open(fpath)
if todayPage, ok := handler.(*page.Page); ok {
// Special handling for Today pages
app.nonStaticFiles = append(app.nonStaticFiles, todayPage.FileDependencies()...)
+ // Track registered paths here; localization causes paths to overlap pretty frequently
+ // In the future, it may be better to have a custom ServeMux for this.
+ registered := make([]string, 0)
for _, lang := range todayPage.Languages() {
translatedExpr := expr
translations, ok := todayPage.Translations()[lang]
if ok {
translatedExpr = localization.TranslatePath(todayPage.DefaultLanguage(), lang, expr, translations)
}
+ if slices.Contains(registered, translatedExpr) {
+ continue
+ }
+ registered = append(registered, translatedExpr)
for _, middleware := range app.preHandler {
handler = middleware(handler)
if err != nil {
return "", err
}
- raw := html.UnescapeString(buf.String())
+ // I don't remember why I removed this, but I trust my past self to have
+ // had a good reason
+ // raw := html.UnescapeString(buf.String())
// Clean boolean attributes
- raw = removeEmptyAttrValues(raw)
+ raw := removeEmptyAttrValues(buf.String())
return raw, nil
}