diff options
author | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-17 17:22:24 +0300 |
---|---|---|
committer | Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com> | 2019-08-17 19:50:16 +0300 |
commit | 4b4bdcfe740d988e4cfb4fee53eced6985576abd (patch) | |
tree | 5ff05e1282d5e0443f0dfe33bec7ce4ffe36dd10 /hugolib | |
parent | 18836a71ce7b671fa71dd1318b99fc661755e94d (diff) |
hugolib: Allow index.md inside bundles
Fixes #6208
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/pagebundler_test.go | 42 | ||||
-rw-r--r-- | hugolib/pages_capture.go | 5 |
2 files changed, 47 insertions, 0 deletions
diff --git a/hugolib/pagebundler_test.go b/hugolib/pagebundler_test.go index a12dd713e..4b3eef512 100644 --- a/hugolib/pagebundler_test.go +++ b/hugolib/pagebundler_test.go @@ -1176,3 +1176,45 @@ Num Pages: {{ len .Site.Pages }} ) } + +// #6208 +func TestBundleIndexInSubFolder(t *testing.T) { + config := ` +baseURL = "https://example.com" + +` + + const pageContent = `--- +title: %q +--- +` + createPage := func(s string) string { + return fmt.Sprintf(pageContent, s) + } + + b := newTestSitesBuilder(t).WithConfigFile("toml", config) + b.WithLogger(loggers.NewWarningLogger()) + + b.WithTemplates("_default/single.html", `{{ range .Resources }} +{{ .ResourceType }}|{{ .Title }}| +{{ end }} + + +`) + + b.WithContent("bundle/index.md", createPage("bundle index")) + b.WithContent("bundle/p1.md", createPage("bundle p1")) + b.WithContent("bundle/sub/p2.md", createPage("bundle sub p2")) + b.WithContent("bundle/sub/index.md", createPage("bundle sub index")) + b.WithContent("bundle/sub/data.json", "data") + + b.Build(BuildCfg{}) + + b.AssertFileContent("public/bundle/index.html", ` + json|sub/data.json| + page|bundle p1| + page|bundle sub index| + page|bundle sub p2| +`) + +} diff --git a/hugolib/pages_capture.go b/hugolib/pages_capture.go index f332e85a8..591b8e317 100644 --- a/hugolib/pages_capture.go +++ b/hugolib/pages_capture.go @@ -370,6 +370,11 @@ func (c *pagesCollector) addToBundle(info hugofs.FileMetaInfo, btyp bundleDirTyp lang := c.getLang(info) bundle := getBundle(lang) isBundleHeader := c.isBundleHeader(info) + if bundle != nil && isBundleHeader { + // index.md file inside a bundle, see issue 6208. + info.Meta()["classifier"] = files.ContentClassContent + isBundleHeader = false + } classifier := info.Meta().Classifier() isContent := classifier == files.ContentClassContent if bundle == nil { |