much stuffs

This commit is contained in:
2025-09-23 19:51:11 +03:00
parent 13f38313ac
commit 9b4c53778d
2 changed files with 9 additions and 6 deletions

View File

@@ -7,7 +7,9 @@ build:
@echo "Copying templates and static..."
mkdir -p $(BUILD_DIR)/templates
mkdir -p $(BUILD_DIR)/static
mkdir -p $(BUILD_DIR)/pages
cp -r templates/* $(BUILD_DIR)/templates/
cp -r pages/* $(BUILD_DIR)/pages/
cp -r static/* $(BUILD_DIR)/static/
clean:
rm -rf $(BUILD_DIR)

13
main.go
View File

@@ -13,12 +13,13 @@ func pageHandler(w http.ResponseWriter, r *http.Request) {
path = "/home"
}
tmpl, err := template.ParseFiles(
filepath.Join("templates/layout.html"),
filepath.Join("templates/header.html"),
filepath.Join("templates/footer.html"),
filepath.Join("pages/"+path+".html"),
)
tmpl, err := template.Must(template.ParseGlob("templates/*.html")).Clone()
if err != nil {
http.NotFound(w, r)
return
}
_, err = tmpl.ParseFiles(filepath.Join("pages", path+".html"))
if err != nil {
http.NotFound(w, r)
return