aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/hugo_sites_build_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-01-30 17:51:18 +0100
committerBjørn Erik Pedersen <[email protected]>2018-01-30 18:53:07 +0100
commitae742cb1bdf35b81aa0ede5453da6b0c4a4fccf2 (patch)
treef2922d4343f9819e7ff4220ebc333b467c8f0d4b /hugolib/hugo_sites_build_test.go
parentfeeed073c3320b09fb38168ce272ac88b987f1d2 (diff)
downloadhugo-ae742cb1bdf35b81aa0ede5453da6b0c4a4fccf2.tar.gz
hugo-ae742cb1bdf35b81aa0ede5453da6b0c4a4fccf2.zip
Fix language params handling
This fixes some issues with language params handling by separating params from configuration values per language. This means that you can now do this: ```toml [languages] [languages.en] languageName = "English" weight = 1 title = "My Cool Site" [languages.en.params] myParam = "Hi!" ``` This is not a breaking change, but the above is a less suprising way of configuring custom params. It also fixes some hard-to-debug corner-cases in multilingual sites. Fixes #4356 Fixes #4352
Diffstat (limited to 'hugolib/hugo_sites_build_test.go')
-rw-r--r--hugolib/hugo_sites_build_test.go28
1 files changed, 22 insertions, 6 deletions
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index cc3a940de..0cececfd7 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -141,6 +141,9 @@ func doTestMultiSitesMainLangInRoot(t *testing.T, defaultInSubDir bool) {
func TestMultiSitesWithTwoLanguages(t *testing.T) {
t.Parallel()
+
+ assert := require.New(t)
+
mm := afero.NewMemMapFs()
writeToFs(t, mm, "config.toml", `
@@ -152,11 +155,15 @@ defaultContentLanguage = "nn"
languageName = "Nynorsk"
weight = 1
title = "Tittel på Nynorsk"
+[languages.nn.params]
+p1 = "p1nn"
[languages.en]
title = "Title in English"
languageName = "English"
weight = 2
+[languages.en.params]
+p1 = "p1en"
`,
)
@@ -176,15 +183,24 @@ weight = 2
// Add some data
writeSource(t, fs, filepath.Join("data", "hugo.toml"), "slogan = \"Hugo Rocks!\"")
- require.NoError(t, sites.Build(BuildCfg{}))
- require.Len(t, sites.Sites, 2)
+ assert.NoError(sites.Build(BuildCfg{}))
+ assert.Len(sites.Sites, 2)
nnSite := sites.Sites[0]
- nnSiteHome := nnSite.getPage(KindHome)
- require.Len(t, nnSiteHome.AllTranslations(), 2)
- require.Len(t, nnSiteHome.Translations(), 1)
- require.True(t, nnSiteHome.IsTranslated())
+ nnHome := nnSite.getPage(KindHome)
+ assert.Len(nnHome.AllTranslations(), 2)
+ assert.Len(nnHome.Translations(), 1)
+ assert.True(nnHome.IsTranslated())
+
+ enHome := sites.Sites[1].getPage(KindHome)
+
+ p1, err := enHome.Param("p1")
+ assert.NoError(err)
+ assert.Equal("p1en", p1)
+ p1, err = nnHome.Param("p1")
+ assert.NoError(err)
+ assert.Equal("p1nn", p1)
}
//