aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib/pagecollections_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-03-09 14:01:28 +0100
committerBjørn Erik Pedersen <[email protected]>2020-03-09 16:11:50 +0100
commit6cceef65c2f4b7c262bf67a249867658112b6de4 (patch)
tree2482c6f5af228951ba39c6d4c19e53b6269fd853 /hugolib/pagecollections_test.go
parentffcb4aeb8e392a80da7cad0f1e03a4102efb24ec (diff)
downloadhugo-6cceef65c2f4b7c262bf67a249867658112b6de4.tar.gz
hugo-6cceef65c2f4b7c262bf67a249867658112b6de4.zip
Fix ambigous error on site.GetPage
Fixes #7016
Diffstat (limited to 'hugolib/pagecollections_test.go')
-rw-r--r--hugolib/pagecollections_test.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/hugolib/pagecollections_test.go b/hugolib/pagecollections_test.go
index 690a315a8..4d95bcffa 100644
--- a/hugolib/pagecollections_test.go
+++ b/hugolib/pagecollections_test.go
@@ -334,3 +334,52 @@ NOT FOUND
b.AssertFileContent("public/who/index.html", `NOT FOUND`)
}
+
+// https://github.com/gohugoio/hugo/issues/7016
+func TestGetPageMultilingual(t *testing.T) {
+ b := newTestSitesBuilder(t)
+
+ b.WithConfigFile("yaml", `
+baseURL: "http://example.org/"
+languageCode: "en-us"
+defaultContentLanguage: ru
+title: "My New Hugo Site"
+uglyurls: true
+
+languages:
+ ru: {}
+ en: {}
+`)
+
+ b.WithContent(
+ "docs/1.md", "\n---title: p1\n---",
+ "news/1.md", "\n---title: p1\n---",
+ "news/1.en.md", "\n---title: p1en\n---",
+ "news/about/1.md", "\n---title: about1\n---",
+ "news/about/1.en.md", "\n---title: about1en\n---",
+ )
+
+ b.WithTemplates("index.html", `
+{{ with site.GetPage "docs/1" }}
+ Docs p1: {{ .Title }}
+{{ else }}
+NOT FOUND
+{{ end }}
+`)
+
+ b.Build(BuildCfg{})
+
+ b.AssertFileContent("public/index.html", `Docs p1: p1`)
+ b.AssertFileContent("public/en/index.html", `NOT FOUND`)
+
+}
+
+func TestShouldDoSimpleLookup(t *testing.T) {
+ c := qt.New(t)
+
+ c.Assert(shouldDoSimpleLookup("foo.md"), qt.Equals, true)
+ c.Assert(shouldDoSimpleLookup("/foo.md"), qt.Equals, true)
+ c.Assert(shouldDoSimpleLookup("./foo.md"), qt.Equals, false)
+ c.Assert(shouldDoSimpleLookup("docs/foo.md"), qt.Equals, false)
+
+}