feat: update site
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user