feat: update site

This commit is contained in:
2024-11-22 15:02:29 -05:00
parent 4b1b6b4369
commit 79327510d7
9 changed files with 124 additions and 52 deletions

View File

@@ -7,6 +7,7 @@ import (
"html/template"
"io/fs"
"path"
"path/filepath"
"strings"
)
@@ -14,24 +15,28 @@ var templates map[string]*template.Template
func init() {
templates = make(map[string]*template.Template)
fs.WalkDir(templateContent, "templates", func(p string, d fs.DirEntry, err error) error {
fs.WalkDir(templateDir, "templates", func(p string, d fs.DirEntry, err error) error {
if d.IsDir() || !strings.HasSuffix(p, ".html") {
return nil
}
basePath := path.Base(p)
templates[basePath] = template.Must(template.ParseFS(templateContent, p, "templates/_layout.html.tmpl"))
fmt.Println(path.Base(p))
basePath := strings.TrimSuffix(path.Base(p), filepath.Ext(p))
templates[basePath] = template.Must(template.ParseFS(templateDir, p, "templates/_layout.html.tmpl"))
return nil
})
fmt.Printf("successfully parsed templates: ")
for k, t := range templates {
fmt.Printf("%s: %s \n", k, t.Name())
fmt.Println("Parsed templates")
for k, ts := range templates {
fmt.Printf("%s: ", k)
for _, t := range ts.Templates() {
fmt.Printf("%s ", t.Name())
}
fmt.Println()
}
fmt.Println()
}
//go:embed templates/*
var templateContent embed.FS
var templateDir embed.FS
//go:embed static/*
var staticContent embed.FS