feat: aliases (#5)

Reviewed-on: yw5n/yw5ncom#5
This commit is contained in:
ange 2025-04-05 10:17:05 +00:00
parent c4e53afdf1
commit abd9218561
19 changed files with 242 additions and 176 deletions

View file

@ -12,10 +12,10 @@ var TMPL map[string][]byte
func generateTmpl() {
files, _ := filepath.Glob("html/*.html")
re := regexp.MustCompile("html/(.+).html")
names := make([]string, len(files))
pages := make([]string, len(files))
for i, f := range files {
names[i] = re.FindStringSubmatch(f)[1]
pages[i] = re.FindStringSubmatch(f)[1]
}
TMPL = make(map[string][]byte, len(files))
for i, f := range files {
@ -23,9 +23,9 @@ func generateTmpl() {
t, _ := template.ParseFiles(f)
t.ParseGlob("tmpl/*.tmpl")
t.Execute(b, map[string]any{
"name": names[i],
"names": names,
"page": pages[i],
"pages": pages,
})
TMPL[names[i]] = b.Bytes()
TMPL[pages[i]] = b.Bytes()
}
}