aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/site_output.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2017-03-09 19:19:29 +0100
committerBjørn Erik Pedersen <[email protected]>2017-03-27 15:43:56 +0200
commit6bf010fed432e5574e19fd2946ee6397d895950e (patch)
tree75282ccbd526adc8dba62f9392db282b3bcec49f /hugolib/site_output.go
parentc8fff9501d424882a42f750800d9982ec47df640 (diff)
downloadhugo-6bf010fed432e5574e19fd2946ee6397d895950e.tar.gz
hugo-6bf010fed432e5574e19fd2946ee6397d895950e.zip
hugolib: Refactor/-work the permalink/target path logic
This is a pretty fundamental change in Hugo, but absolutely needed if we should have any hope of getting "multiple outputs" done. This commit's goal is to say: * Every file target path is created by `createTargetPath`, i.e. one function for all. * That function takes every page and site parameter into account, to avoid fragile string parsing to uglify etc. later on. * The path creation logic has full test coverage. * All permalinks, paginator URLs etc. are then built on top of that same logic. Fixes #1252 Fixes #2110 Closes #2374 Fixes #1885 Fixes #3102 Fixes #3179 Fixes #1641 Fixes #1989
Diffstat (limited to 'hugolib/site_output.go')
-rw-r--r--hugolib/site_output.go33
1 files changed, 26 insertions, 7 deletions
diff --git a/hugolib/site_output.go b/hugolib/site_output.go
index 7f6fa2d4a..53d3f9799 100644
--- a/hugolib/site_output.go
+++ b/hugolib/site_output.go
@@ -14,18 +14,13 @@
package hugolib
import (
+ "path"
"strings"
+ "github.com/spf13/hugo/config"
"github.com/spf13/hugo/output"
)
-var defaultOutputDefinitions = siteOutputDefinitions{
- // All have HTML
- siteOutputDefinition{ExcludedKinds: "", Outputs: []output.Type{output.HTMLType}},
- // Some have RSS
- siteOutputDefinition{ExcludedKinds: "page", Outputs: []output.Type{output.RSSType}},
-}
-
type siteOutputDefinitions []siteOutputDefinition
type siteOutputDefinition struct {
@@ -48,3 +43,27 @@ func (defs siteOutputDefinitions) ForKind(kind string) []output.Type {
return result
}
+
+func createSiteOutputDefinitions(cfg config.Provider) siteOutputDefinitions {
+
+ var defs siteOutputDefinitions
+
+ // All have HTML
+ defs = append(defs, siteOutputDefinition{ExcludedKinds: "", Outputs: []output.Type{output.HTMLType}})
+
+ // TODO(bep) output deprecate rssURI
+ rssBase := cfg.GetString("rssURI")
+ if rssBase == "" {
+ rssBase = "index"
+ }
+
+ // RSS has now a well defined media type, so strip any suffix provided
+ rssBase = strings.TrimSuffix(rssBase, path.Ext(rssBase))
+ rssType := output.RSSType
+ rssType.BaseName = rssBase
+
+ // Some have RSS
+ defs = append(defs, siteOutputDefinition{ExcludedKinds: "page", Outputs: []output.Type{rssType}})
+
+ return defs
+}