diff options
author | Nate Finch <nate.finch@gmail.com> | 2016-10-15 14:35:32 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2016-10-15 16:25:05 +0300 |
commit | 10a773cde7a7d5860512917ae2aa14b683318000 (patch) | |
tree | 2210c46781c6040a8fdc2783eda7b9957f53e167 /target | |
parent | 8b43d39ef312e5b9e3549aa8fa75a1464a467ae8 (diff) |
Implement support for alias templates
This change adds a canonical alias.html template that is used for page
redirects, and passes the page as data to the template under .Page
Fixes #2533
Closes #2576
Diffstat (limited to 'target')
-rw-r--r-- | target/htmlredirect.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/target/htmlredirect.go b/target/htmlredirect.go index 81051589a..20e064c88 100644 --- a/target/htmlredirect.go +++ b/target/htmlredirect.go @@ -39,7 +39,7 @@ func init() { type AliasPublisher interface { Translator - Publish(string, string) error + Publish(path string, permalink string, page interface{}) error } type HTMLRedirectAlias struct { @@ -121,9 +121,10 @@ func (h *HTMLRedirectAlias) Translate(alias string) (aliasPath string, err error type AliasNode struct { Permalink string + Page interface{} } -func (h *HTMLRedirectAlias) Publish(path string, permalink string) (err error) { +func (h *HTMLRedirectAlias) Publish(path string, permalink string, page interface{}) (err error) { if path, err = h.Translate(path); err != nil { jww.ERROR.Printf("%s, skipping.", err) return nil @@ -137,10 +138,11 @@ func (h *HTMLRedirectAlias) Publish(path string, permalink string) (err error) { template := defaultAliasTemplates if h.Templates != nil { template = h.Templates + t = "alias.html" } buffer := new(bytes.Buffer) - err = template.ExecuteTemplate(buffer, t, &AliasNode{permalink}) + err = template.ExecuteTemplate(buffer, t, &AliasNode{permalink, page}) if err != nil { return } |