aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/hugo_sites_build_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2018-01-17 19:26:34 +0100
committerBjørn Erik Pedersen <[email protected]>2018-01-17 22:27:25 +0100
commit9409bc0f799a8057836a14ccdf2833a55902175e (patch)
tree13b6564180b6595e9444d9c64f8a386df8a08a17 /hugolib/hugo_sites_build_test.go
parent4eb1650bec0be0da57947fc8ee9b3c641d5e35dd (diff)
downloadhugo-9409bc0f799a8057836a14ccdf2833a55902175e.tar.gz
hugo-9409bc0f799a8057836a14ccdf2833a55902175e.zip
Improve .Site.GetPage for regular translated pages
You can still use the full path with extensions, but to get the current language version: * If the content file lives in `/content/blog/mypost.en.md` * Use `.Site.GetPage "page" "blog/mypost"` Fixes #4285
Diffstat (limited to 'hugolib/hugo_sites_build_test.go')
-rw-r--r--hugolib/hugo_sites_build_test.go15
1 files changed, 15 insertions, 0 deletions
diff --git a/hugolib/hugo_sites_build_test.go b/hugolib/hugo_sites_build_test.go
index c48e6b9a4..4dc4423cd 100644
--- a/hugolib/hugo_sites_build_test.go
+++ b/hugolib/hugo_sites_build_test.go
@@ -299,6 +299,20 @@ func doTestMultiSitesBuild(t *testing.T, configTemplate, configSuffix string) {
require.Equal(t, "fr", frenchPage.Lang())
}
+ // See https://github.com/gohugoio/hugo/issues/4285
+ // Before Hugo 0.33 you had to be explicit with the content path to get the correct Page, which
+ // isn't ideal in a multilingual setup. You want a way to get the current language version if available.
+ // Now you can do lookups with translation base name to get that behaviour.
+ // Let us test all the regular page variants:
+ getPageDoc1En := enSite.getPage(KindPage, filepath.ToSlash(doc1en.Path()))
+ getPageDoc1EnBase := enSite.getPage(KindPage, "sect/doc1")
+ getPageDoc1Fr := frSite.getPage(KindPage, filepath.ToSlash(doc1fr.Path()))
+ getPageDoc1FrBase := frSite.getPage(KindPage, "sect/doc1")
+ require.Equal(t, doc1en, getPageDoc1En)
+ require.Equal(t, doc1fr, getPageDoc1Fr)
+ require.Equal(t, doc1en, getPageDoc1EnBase)
+ require.Equal(t, doc1fr, getPageDoc1FrBase)
+
// Check redirect to main language, French
languageRedirect := readDestination(t, fs, "public/index.html")
require.True(t, strings.Contains(languageRedirect, "0; url=http://example.com/blog/fr"), languageRedirect)
@@ -683,6 +697,7 @@ title = "Svenska"
// Veriy Swedish site
require.Len(t, svSite.RegularPages, 1)
svPage := svSite.RegularPages[0]
+
require.Equal(t, "Swedish Contentfile", svPage.title)
require.Equal(t, "sv", svPage.Lang())
require.Len(t, svPage.Translations(), 2)