mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-30 01:31:06 -05:00
hugolib, output: Add NotAlternative to OutputFormat
To make sure CSS and similar does not appear in the AlternativeOutputFormats list.
This commit is contained in:
parent
9e69a92e85
commit
2874fc75ce
3 changed files with 16 additions and 9 deletions
|
@ -177,8 +177,6 @@ type OutputFormat struct {
|
||||||
// This is value is fetched from the output format definition.
|
// This is value is fetched from the output format definition.
|
||||||
// Note that for pages with only one output format,
|
// Note that for pages with only one output format,
|
||||||
// this method will always return "canonical".
|
// 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".
|
// As an example, the AMP output format will, by default, return "amphtml".
|
||||||
//
|
//
|
||||||
// See:
|
// See:
|
||||||
|
@ -222,10 +220,12 @@ func newOutputFormat(p *Page, f output.Format) *OutputFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
// OutputFormats gives the alternative output formats for this PageOutput.
|
// 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) {
|
func (p *PageOutput) AlternativeOutputFormats() (OutputFormats, error) {
|
||||||
var o OutputFormats
|
var o OutputFormats
|
||||||
for _, of := range p.OutputFormats() {
|
for _, of := range p.OutputFormats() {
|
||||||
if of.f == p.outputFormat {
|
if of.f.NotAlternative || of.f == p.outputFormat {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
o = append(o, of)
|
o = append(o, of)
|
||||||
|
|
|
@ -290,7 +290,7 @@ func (s *Site) renderSitemap() error {
|
||||||
n.Data["Pages"] = pages
|
n.Data["Pages"] = pages
|
||||||
n.Pages = pages
|
n.Pages = pages
|
||||||
|
|
||||||
// TODO(bep) output
|
// TODO(bep) we have several of these
|
||||||
if err := page.initTargetPathDescriptor(); err != nil {
|
if err := page.initTargetPathDescriptor(); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,12 @@ type Format struct {
|
||||||
|
|
||||||
// Enable to ignore the global uglyURLs setting.
|
// Enable to ignore the global uglyURLs setting.
|
||||||
NoUgly bool
|
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 (
|
var (
|
||||||
|
@ -93,6 +99,7 @@ var (
|
||||||
BaseName: "styles",
|
BaseName: "styles",
|
||||||
IsPlainText: true,
|
IsPlainText: true,
|
||||||
Rel: "stylesheet",
|
Rel: "stylesheet",
|
||||||
|
NotAlternative: true,
|
||||||
}
|
}
|
||||||
CSVFormat = Format{
|
CSVFormat = Format{
|
||||||
Name: "CSV",
|
Name: "CSV",
|
||||||
|
|
Loading…
Reference in a new issue