FEAT: directory stylesheet overrides

This commit is contained in:
claire treise 2026-03-17 20:16:28 +01:00
parent 523aa894d0
commit eac93e08bb
3 changed files with 16 additions and 2 deletions

11
main.go
View file

@ -29,6 +29,7 @@ type (
Root bool
Files []*File
Readme template.HTML
CSS template.CSS
}
File struct {
@ -181,6 +182,15 @@ func main() {
return
}
// load index.css if present
var customCSS template.CSS
cssPath := filepath.Join(fpath, "index.css")
if cssInfo, err := os.Stat(cssPath); err == nil && !cssInfo.IsDir() {
if src, err := os.ReadFile(cssPath); err == nil {
customCSS = template.CSS(src)
}
}
// embeded readme
var readmeHTML template.HTML
entries, err := os.ReadDir(fpath)
@ -205,6 +215,7 @@ func main() {
Name: r.URL.Path,
Files: []*File{},
Readme: readmeHTML,
CSS: customCSS,
}
fsDir := os.DirFS(fpath)