diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-08 11:15:28 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-04-08 11:21:12 +0200 |
commit | 2874fc75ce45b17fd4457440e55660d7118fbc46 (patch) | |
tree | e18af3d9a659386c99f4b6562b150fb4d0ae7297 | |
parent | 9e69a92e85937c6e59839e58937ed1db1e497557 (diff) |
hugolib, output: Add NotAlternative to OutputFormat
To make sure CSS and similar does not appear in the AlternativeOutputFormats list.
-rw-r--r-- | hugolib/page_output.go | 6 | ||||
-rw-r--r-- | hugolib/site_render.go | 2 | ||||
-rw-r--r-- | output/outputFormat.go | 17 |
3 files changed, 16 insertions, 9 deletions
diff --git a/hugolib/page_output.go b/hugolib/page_output.go index c6a72d324..7b299b575 100644 --- a/hugolib/page_output.go +++ b/hugolib/page_output.go @@ -177,8 +177,6 @@ type OutputFormat struct { // This is value is fetched from the output format definition. // Note that for pages with only one output format, // this method will always return "canonical". - // TODO(bep) output -- the above may not be correct for CSS etc. Figure out a way around that. - // TODO(bep) output -- re the above, maybe add a "alternate" filter to AlternativeOutputFormats. // As an example, the AMP output format will, by default, return "amphtml". // // See: @@ -222,10 +220,12 @@ func newOutputFormat(p *Page, f output.Format) *OutputFormat { } // OutputFormats gives the alternative output formats for this PageOutput. +// Note that we use the term "alternative" and not "alternate" here, as it +// does not necessarily replace the other format, it is an alternative representation. func (p *PageOutput) AlternativeOutputFormats() (OutputFormats, error) { var o OutputFormats for _, of := range p.OutputFormats() { - if of.f == p.outputFormat { + if of.f.NotAlternative || of.f == p.outputFormat { continue } o = append(o, of) diff --git a/hugolib/site_render.go b/hugolib/site_render.go index 0c9da2134..17a14bd10 100644 --- a/hugolib/site_render.go +++ b/hugolib/site_render.go @@ -290,7 +290,7 @@ func (s *Site) renderSitemap() error { n.Data["Pages"] = pages n.Pages = pages - // TODO(bep) output + // TODO(bep) we have several of these if err := page.initTargetPathDescriptor(); err != nil { return err } diff --git a/output/outputFormat.go b/output/outputFormat.go index bd0236278..0845b5d31 100644 --- a/output/outputFormat.go +++ b/output/outputFormat.go @@ -63,6 +63,12 @@ type Format struct { // Enable to ignore the global uglyURLs setting. NoUgly bool + + // Enable if it doesn't make sense to include this format in an alternative + // format listing, CSS being one good example. + // Note that we use the term "alternative" and not "alternate" here, as it + // does not necessarily replace the other format, it is an alternative representation. + NotAlternative bool } var ( @@ -88,11 +94,12 @@ var ( } CSSFormat = Format{ - Name: "CSS", - MediaType: media.CSSType, - BaseName: "styles", - IsPlainText: true, - Rel: "stylesheet", + Name: "CSS", + MediaType: media.CSSType, + BaseName: "styles", + IsPlainText: true, + Rel: "stylesheet", + NotAlternative: true, } CSVFormat = Format{ Name: "CSV", |