Fix template lookup

This commit is contained in:
Adnan Maolood 2020-11-27 18:49:53 -05:00
parent f519317ebd
commit be14245284
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
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
}

View file

@ -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),