summaryrefslogtreecommitdiffstats
path: root/hugolib/page_output.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-24 11:25:25 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2017-03-27 15:43:56 +0200
commit87188496fbb68c39567ec3ee3a55a9305a13e48b (patch)
treeb70e4c3ce41c4d97fe70ce8cb06c4ee0e819084c /hugolib/page_output.go
parent0c4701f0effbf651891979b925073f6fc5d26a82 (diff)
hugolib, output: Handle aliases for all HTML formats
Diffstat (limited to 'hugolib/page_output.go')
-rw-r--r--hugolib/page_output.go16
1 files changed, 10 insertions, 6 deletions
diff --git a/hugolib/page_output.go b/hugolib/page_output.go
index ec662bf23..2416e22b5 100644
--- a/hugolib/page_output.go
+++ b/hugolib/page_output.go
@@ -152,17 +152,21 @@ func (o OutputFormat) MediaType() media.Type {
// OutputFormats gives the output formats for this Page.
func (p *Page) OutputFormats() OutputFormats {
var o OutputFormats
- isCanonical := len(p.outputFormats) == 1
for _, f := range p.outputFormats {
- rel := f.Rel
- if isCanonical {
- rel = "canonical"
- }
- o = append(o, &OutputFormat{Rel: rel, f: f, p: p})
+ o = append(o, newOutputFormat(p, f))
}
return o
}
+func newOutputFormat(p *Page, f output.Format) *OutputFormat {
+ rel := f.Rel
+ isCanonical := len(p.outputFormats) == 1
+ if isCanonical {
+ rel = "canonical"
+ }
+ return &OutputFormat{Rel: rel, f: f, p: p}
+}
+
// OutputFormats gives the alternative output formats for this PageOutput.
func (p *PageOutput) AlternativeOutputFormats() (OutputFormats, error) {
var o OutputFormats