diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-17 18:04:07 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2017-05-17 19:00:15 +0300 |
commit | 6e2f2dd8d3ca61c92a2ee8824fbf05cadef08425 (patch) | |
tree | b8c8c97fca661ab6208d8ddd6d46ab68cf2e63b0 /hugolib/site_output.go | |
parent | 94b5be67fc73b87d114d94a7bb1a33ab997f30f1 (diff) |
hugolib: Fix output formats override when no outputs definition given
A common use case for this is to redefine the built-in output format `RSS` to give it a different URL.
Before this commit, that was not possible without also providing an `outputs` definition.
Fixes #3447
Diffstat (limited to 'hugolib/site_output.go')
-rw-r--r-- | hugolib/site_output.go | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/hugolib/site_output.go b/hugolib/site_output.go index 684ff2e73..6b72ea9b6 100644 --- a/hugolib/site_output.go +++ b/hugolib/site_output.go @@ -26,7 +26,7 @@ import ( func createSiteOutputFormats(allFormats output.Formats, cfg config.Provider) (map[string]output.Formats, error) { if !cfg.IsSet("outputs") { - return createDefaultOutputFormats(cfg) + return createDefaultOutputFormats(allFormats, cfg) } outFormats := make(map[string]output.Formats) @@ -64,20 +64,22 @@ func createSiteOutputFormats(allFormats output.Formats, cfg config.Provider) (ma } -func createDefaultOutputFormats(cfg config.Provider) (map[string]output.Formats, error) { +func createDefaultOutputFormats(allFormats output.Formats, cfg config.Provider) (map[string]output.Formats, error) { outFormats := make(map[string]output.Formats) + rssOut, _ := allFormats.GetByName(output.RSSFormat.Name) + htmlOut, _ := allFormats.GetByName(output.HTMLFormat.Name) + for _, kind := range allKinds { var formats output.Formats // All have HTML - formats = append(formats, output.HTMLFormat) + formats = append(formats, htmlOut) // All but page have RSS if kind != KindPage { - rssType := output.RSSFormat rssBase := cfg.GetString("rssURI") if rssBase == "" || rssBase == "index.xml" { - rssBase = rssType.BaseName + rssBase = rssOut.BaseName } else { // Remove in Hugo 0.22. helpers.Deprecated("Site config", "rssURI", "Set baseName in outputFormats.RSS", false) @@ -85,8 +87,8 @@ func createDefaultOutputFormats(cfg config.Provider) (map[string]output.Formats, rssBase = strings.TrimSuffix(rssBase, path.Ext(rssBase)) } - rssType.BaseName = rssBase - formats = append(formats, rssType) + rssOut.BaseName = rssBase + formats = append(formats, rssOut) } |