updated nav

This commit is contained in:
2025-12-30 11:37:29 -07:00
parent 76fade5cdc
commit 493d15eae8
10 changed files with 108 additions and 19 deletions
+17
View File
@@ -1,9 +1,11 @@
package site
import (
"errors"
"fmt"
"net/http"
"net/url"
"os"
"path"
"path/filepath"
"strings"
@@ -51,6 +53,14 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) {
acct,
)
if err != nil {
// TODO: handle 401
// TODO: handle 403
// TODO: handle 404
if isFileNotFoundError(err) {
}
// TODO: handle 'not found' as a 404?
fmt.Println("[ERROR]: failed to load or parse layout template:", err)
http.Redirect(w, r, "/", http.StatusTemporaryRedirect)
@@ -60,6 +70,13 @@ func (s *Server) serveTemplates(w http.ResponseWriter, r *http.Request) {
w.Write(b)
}
func isFileNotFoundError(err error) bool {
var pe *os.PathError
isPathErr := errors.As(err, &pe)
return isPathErr && pe.Err != nil && pe.Err.Error() == "no such file or directory"
}
// TODO: clean this up...
// TODO: somehow tell what the path params are and pass them up.
// - then consider pushing this functionality into the template library.