Browse Source

Fix template lookup

master
Adnan Maolood 7 months ago
parent
commit
be14245284
  1. 2
      dir.go
  2. 4
      main.go

2
dir.go

@ -93,7 +93,7 @@ func (d *Dir) manipulate(cfg *Config) error {
// Manipulate pages
for i := range d.Pages {
var b strings.Builder
tmpl := cfg.Templates.FindTemplate(d.Pages[i].Path, "page.gmi")
tmpl := cfg.Templates.FindTemplate(d.Path, "page.gmi")
if err := tmpl.Execute(&b, d.Pages[i]); err != nil {
return err
}

4
main.go

@ -78,7 +78,9 @@ func outputHTML(p *Page, cfg *Config) (path string, content []byte) {
}
var b bytes.Buffer
tmpl := cfg.Templates.FindTemplate(pathpkg.Dir(path), "output.html")
// clean path to remove trailing slash
dir := pathpkg.Dir(pathpkg.Clean(p.Path))
tmpl := cfg.Templates.FindTemplate(dir, "output.html")
tmpl.Execute(&b, &htmlCtx{
Title: p.Title,
Content: string(content),

Loading…
Cancel
Save