Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-03 11:40:59 +0300
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2021-07-03 16:53:21 +0300
commite451b984cfb45b54a3972cefa59a02d50b0b0fd2 (patch)
tree6eb25f689c753c3a65edd9ca859e2ce40afd4a6d /hugolib
parentb4d60b3db1c05816458cc4f4f29d42156845e6c1 (diff)
Fix panic when theme has permalinks config
Fixes #8724
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/config.go6
-rw-r--r--hugolib/config_test.go43
2 files changed, 44 insertions, 5 deletions
diff --git a/hugolib/config.go b/hugolib/config.go
index 3e3700433..65b269ab6 100644
--- a/hugolib/config.go
+++ b/hugolib/config.go
@@ -255,9 +255,9 @@ func (l configLoader) applyConfigDefaults() error {
"relativeURLs": false,
"removePathAccents": false,
"titleCaseStyle": "AP",
- "taxonomies": map[string]string{"tag": "tags", "category": "categories"},
- "permalinks": make(map[string]string),
- "sitemap": config.Sitemap{Priority: -1, Filename: "sitemap.xml"},
+ "taxonomies": maps.Params{"tag": "tags", "category": "categories"},
+ "permalinks": maps.Params{},
+ "sitemap": maps.Params{"priority": -1, "filename": "sitemap.xml"},
"disableLiveReload": false,
"pluralizeListTitles": true,
"forceSyncStatic": false,
diff --git a/hugolib/config_test.go b/hugolib/config_test.go
index 810ab18f5..6de274717 100644
--- a/hugolib/config_test.go
+++ b/hugolib/config_test.go
@@ -185,7 +185,7 @@ name = "menu-theme"
`
- buildForConfig := func(mainConfig, themeConfig string) *sitesBuilder {
+ buildForConfig := func(t testing.TB, mainConfig, themeConfig string) *sitesBuilder {
b := newTestSitesBuilder(t)
b.WithConfigFile("toml", mainConfig).WithThemeConfigFile("toml", themeConfig)
return b.Build(BuildCfg{})
@@ -193,7 +193,7 @@ name = "menu-theme"
buildForStrategy := func(t testing.TB, s string) *sitesBuilder {
mainConfig := strings.ReplaceAll(mainConfigTemplate, "MERGE_PARAMS", s)
- return buildForConfig(mainConfig, themeConfig)
+ return buildForConfig(t, mainConfig, themeConfig)
}
c.Run("Merge default", func(c *qt.C) {
@@ -322,6 +322,7 @@ name = "menu-theme"
c.Run("Merge no params in project", func(c *qt.C) {
b := buildForConfig(
+ c,
"baseURL=\"https://example.org\"\ntheme = \"test-theme\"\n",
"[params]\np1 = \"p1 theme\"\n",
)
@@ -335,6 +336,7 @@ name = "menu-theme"
c.Run("Merge language no menus or params in project", func(c *qt.C) {
b := buildForConfig(
+ c,
`
theme = "test-theme"
baseURL = "https://example.com/"
@@ -378,6 +380,43 @@ name = "menu-theme"
)
})
+ // Issue #8724
+ for _, mergeStrategy := range []string{"none", "shallow"} {
+ c.Run(fmt.Sprintf("Merge with sitemap config in theme, mergestrategy %s", mergeStrategy), func(c *qt.C) {
+
+ smapConfigTempl := `[sitemap]
+ changefreq = %q
+ filename = "sitemap.xml"
+ priority = 0.5`
+
+ b := buildForConfig(
+ c,
+ fmt.Sprintf("_merge=%q\nbaseURL=\"https://example.org\"\ntheme = \"test-theme\"\n", mergeStrategy),
+ "baseURL=\"http://example.com\"\n"+fmt.Sprintf(smapConfigTempl, "monthly"),
+ )
+
+ got := b.Cfg.Get("").(maps.Params)
+
+ if mergeStrategy == "none" {
+ b.Assert(got["sitemap"], qt.DeepEquals, maps.Params{
+ "priority": int(-1),
+ "filename": "sitemap.xml",
+ })
+
+ b.AssertFileContent("public/sitemap.xml", "schemas/sitemap")
+ } else {
+ b.Assert(got["sitemap"], qt.DeepEquals, maps.Params{
+ "priority": int(-1),
+ "filename": "sitemap.xml",
+ "changefreq": "monthly",
+ })
+
+ b.AssertFileContent("public/sitemap.xml", "<changefreq>monthly</changefreq>")
+ }
+
+ })
+ }
+
}
func TestLoadConfigFromThemeDir(t *testing.T) {