From 597671cb6b7322f4fbb6bfe29420951c8b4f93eb Mon Sep 17 00:00:00 2001 From: Adnan Maolood Date: Wed, 9 Feb 2022 00:39:48 -0500 Subject: [PATCH] page: Fallback to base template for page/index templates Implements: https://todo.sr.ht/~adnano/kiln/22 --- page.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/page.go b/page.go index 27fbe32..1a35d4a 100644 --- a/page.go +++ b/page.go @@ -169,6 +169,10 @@ func (p *Page) process(cfg *Site, task *Task) error { // Create index if p.index { tmpl, ok := cfg.templates.FindTemplate(p.Path, "index"+task.TemplateExt) + if !ok { + // Try the base template + tmpl, ok = cfg.templates.FindTemplate(p.Path, "base"+task.TemplateExt) + } if ok { var b strings.Builder if err := tmpl.Execute(&b, p); err != nil { @@ -182,6 +186,10 @@ func (p *Page) process(cfg *Site, task *Task) error { for i := range p.Pages { var b strings.Builder tmpl, ok := cfg.templates.FindTemplate(p.Path, "page"+task.TemplateExt) + if !ok { + // Try the base template + tmpl, ok = cfg.templates.FindTemplate(p.Path, "base"+task.TemplateExt) + } if ok { if err := tmpl.Execute(&b, p.Pages[i]); err != nil { return err