Fix template lookup

This commit is contained in:
adnano 2020-11-27 18:49:53 -05:00
parent 943499c3d6
commit 7a5093b046
2 changed files with 4 additions and 2 deletions

2
dir.go
View file

@ -93,7 +93,7 @@ func (d *Dir) manipulate(cfg *Config) error {
// Manipulate pages // Manipulate pages
for i := range d.Pages { for i := range d.Pages {
var b strings.Builder 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 { if err := tmpl.Execute(&b, d.Pages[i]); err != nil {
return err return err
} }

View file

@ -78,7 +78,9 @@ func outputHTML(p *Page, cfg *Config) (path string, content []byte) {
} }
var b bytes.Buffer 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{ tmpl.Execute(&b, &htmlCtx{
Title: p.Title, Title: p.Title,
Content: string(content), Content: string(content),