summaryrefslogtreecommitdiffstats
path: root/hugolib/pagebundler_test.go
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-05-31 09:40:58 +0200
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2019-06-09 16:55:08 +0200
commit3e6cb2cb77e16be5b6ddd4ae55d5fc6bfba2d226 (patch)
tree849651cfad7c4aed5c37691bc516845b6734bd94 /hugolib/pagebundler_test.go
parent8d898ad6672e0ccb62c5a29b6fccab24d980f104 (diff)
hugolib: Fix bundle path when slug is set
Fixes #4870
Diffstat (limited to 'hugolib/pagebundler_test.go')
-rw-r--r--hugolib/pagebundler_test.go39
1 files changed, 34 insertions, 5 deletions
diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go
index 64c1529d8..79e0a107d 100644
--- a/hugolib/pagebundler_test.go
+++ b/hugolib/pagebundler_test.go
@@ -460,7 +460,7 @@ HEADLESS {{< myShort >}}
assert.Equal(1, len(s.headlessPages))
regular := s.getPage(page.KindPage, "a/index")
- assert.Equal("/a/s1/", regular.RelPermalink())
+ assert.Equal("/s1/", regular.RelPermalink())
headless := s.getPage(page.KindPage, "b/index")
assert.NotNil(headless)
@@ -481,12 +481,12 @@ HEADLESS {{< myShort >}}
th := testHelper{s.Cfg, s.Fs, t}
- th.assertFileContent(filepath.FromSlash(workDir+"/public/a/s1/index.html"), "TheContent")
- th.assertFileContent(filepath.FromSlash(workDir+"/public/a/s1/l1.png"), "PNG")
+ th.assertFileContent(filepath.FromSlash(workDir+"/public/s1/index.html"), "TheContent")
+ th.assertFileContent(filepath.FromSlash(workDir+"/public/s1/l1.png"), "PNG")
- th.assertFileNotExist(workDir + "/public/b/s2/index.html")
+ th.assertFileNotExist(workDir + "/public/s2/index.html")
// But the bundled resources needs to be published
- th.assertFileContent(filepath.FromSlash(workDir+"/public/b/s2/l1.png"), "PNG")
+ th.assertFileContent(filepath.FromSlash(workDir+"/public/s2/l1.png"), "PNG")
}
@@ -942,3 +942,32 @@ date: 2017-01-15
b.AssertFileContent("public/mybundle/data.json", "My changed data")
}
+
+// https://github.com/gohugoio/hugo/issues/4870
+func TestBundleSlug(t *testing.T) {
+ t.Parallel()
+ assert := require.New(t)
+
+ const pageTemplate = `---
+title: Title
+slug: %s
+---
+`
+
+ b := newTestSitesBuilder(t)
+
+ b.WithTemplatesAdded("index.html", `{{ range .Site.RegularPages }}|{{ .RelPermalink }}{{ end }}|`)
+ b.WithSimpleConfigFile().
+ WithContent("about/services1/misc.md", fmt.Sprintf(pageTemplate, "this-is-the-slug")).
+ WithContent("about/services2/misc/index.md", fmt.Sprintf(pageTemplate, "this-is-another-slug"))
+
+ b.CreateSites().Build(BuildCfg{})
+
+ b.AssertHome(
+ "|/about/services1/this-is-the-slug/|/",
+ "|/about/services2/this-is-another-slug/|")
+
+ assert.True(b.CheckExists("public/about/services1/this-is-the-slug/index.html"))
+ assert.True(b.CheckExists("public/about/services2/this-is-another-slug/index.html"))
+
+}