mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-25 22:00:58 +02:00
@@ -34,6 +34,7 @@ import (
|
||||
|
||||
"github.com/gohugoio/hugo/hugofs"
|
||||
|
||||
"github.com/gohugoio/hugo/resources/kinds"
|
||||
"github.com/gohugoio/hugo/resources/page"
|
||||
|
||||
"github.com/gohugoio/hugo/htesting"
|
||||
@@ -104,7 +105,7 @@ func TestPageBundlerSiteRegular(t *testing.T) {
|
||||
|
||||
c.Assert(len(s.RegularPages()), qt.Equals, 8)
|
||||
|
||||
singlePage := s.getPage(page.KindPage, "a/1.md")
|
||||
singlePage := s.getPage(kinds.KindPage, "a/1.md")
|
||||
c.Assert(singlePage.BundleType(), qt.Equals, files.ContentClass(""))
|
||||
|
||||
c.Assert(singlePage, qt.Not(qt.IsNil))
|
||||
@@ -150,18 +151,18 @@ func TestPageBundlerSiteRegular(t *testing.T) {
|
||||
// This should be just copied to destination.
|
||||
b.AssertFileContent(filepath.FromSlash("public/assets/pic1.png"), "content")
|
||||
|
||||
leafBundle1 := s.getPage(page.KindPage, "b/my-bundle/index.md")
|
||||
leafBundle1 := s.getPage(kinds.KindPage, "b/my-bundle/index.md")
|
||||
c.Assert(leafBundle1, qt.Not(qt.IsNil))
|
||||
c.Assert(leafBundle1.BundleType(), qt.Equals, files.ContentClassLeaf)
|
||||
c.Assert(leafBundle1.Section(), qt.Equals, "b")
|
||||
sectionB := s.getPage(page.KindSection, "b")
|
||||
sectionB := s.getPage(kinds.KindSection, "b")
|
||||
c.Assert(sectionB, qt.Not(qt.IsNil))
|
||||
home := s.Home()
|
||||
c.Assert(home.BundleType(), qt.Equals, files.ContentClassBranch)
|
||||
|
||||
// This is a root bundle and should live in the "home section"
|
||||
// See https://github.com/gohugoio/hugo/issues/4332
|
||||
rootBundle := s.getPage(page.KindPage, "root")
|
||||
rootBundle := s.getPage(kinds.KindPage, "root")
|
||||
c.Assert(rootBundle, qt.Not(qt.IsNil))
|
||||
c.Assert(rootBundle.Parent().IsHome(), qt.Equals, true)
|
||||
if !ugly {
|
||||
@@ -169,9 +170,9 @@ func TestPageBundlerSiteRegular(t *testing.T) {
|
||||
b.AssertFileContent(filepath.FromSlash("public/cpath/root/cindex.html"), "Single RelPermalink: "+relURLBase+"/cpath/root/")
|
||||
}
|
||||
|
||||
leafBundle2 := s.getPage(page.KindPage, "a/b/index.md")
|
||||
leafBundle2 := s.getPage(kinds.KindPage, "a/b/index.md")
|
||||
c.Assert(leafBundle2, qt.Not(qt.IsNil))
|
||||
unicodeBundle := s.getPage(page.KindPage, "c/bundle/index.md")
|
||||
unicodeBundle := s.getPage(kinds.KindPage, "c/bundle/index.md")
|
||||
c.Assert(unicodeBundle, qt.Not(qt.IsNil))
|
||||
|
||||
pageResources := leafBundle1.Resources().ByType(pageResourceType)
|
||||
@@ -302,7 +303,7 @@ func TestPageBundlerSiteMultilingual(t *testing.T) {
|
||||
|
||||
c.Assert(len(s.AllPages()), qt.Equals, 31)
|
||||
|
||||
bundleWithSubPath := s.getPage(page.KindPage, "lb/index")
|
||||
bundleWithSubPath := s.getPage(kinds.KindPage, "lb/index")
|
||||
c.Assert(bundleWithSubPath, qt.Not(qt.IsNil))
|
||||
|
||||
// See https://github.com/gohugoio/hugo/issues/4312
|
||||
@@ -316,22 +317,22 @@ func TestPageBundlerSiteMultilingual(t *testing.T) {
|
||||
// and probably also just b (aka "my-bundle")
|
||||
// These may also be translated, so we also need to test that.
|
||||
// "bf", "my-bf-bundle", "index.md + nn
|
||||
bfBundle := s.getPage(page.KindPage, "bf/my-bf-bundle/index")
|
||||
bfBundle := s.getPage(kinds.KindPage, "bf/my-bf-bundle/index")
|
||||
c.Assert(bfBundle, qt.Not(qt.IsNil))
|
||||
c.Assert(bfBundle.Language().Lang, qt.Equals, "en")
|
||||
c.Assert(s.getPage(page.KindPage, "bf/my-bf-bundle/index.md"), qt.Equals, bfBundle)
|
||||
c.Assert(s.getPage(page.KindPage, "bf/my-bf-bundle"), qt.Equals, bfBundle)
|
||||
c.Assert(s.getPage(page.KindPage, "my-bf-bundle"), qt.Equals, bfBundle)
|
||||
c.Assert(s.getPage(kinds.KindPage, "bf/my-bf-bundle/index.md"), qt.Equals, bfBundle)
|
||||
c.Assert(s.getPage(kinds.KindPage, "bf/my-bf-bundle"), qt.Equals, bfBundle)
|
||||
c.Assert(s.getPage(kinds.KindPage, "my-bf-bundle"), qt.Equals, bfBundle)
|
||||
|
||||
nnSite := sites.Sites[1]
|
||||
c.Assert(len(nnSite.RegularPages()), qt.Equals, 7)
|
||||
|
||||
bfBundleNN := nnSite.getPage(page.KindPage, "bf/my-bf-bundle/index")
|
||||
bfBundleNN := nnSite.getPage(kinds.KindPage, "bf/my-bf-bundle/index")
|
||||
c.Assert(bfBundleNN, qt.Not(qt.IsNil))
|
||||
c.Assert(bfBundleNN.Language().Lang, qt.Equals, "nn")
|
||||
c.Assert(nnSite.getPage(page.KindPage, "bf/my-bf-bundle/index.nn.md"), qt.Equals, bfBundleNN)
|
||||
c.Assert(nnSite.getPage(page.KindPage, "bf/my-bf-bundle"), qt.Equals, bfBundleNN)
|
||||
c.Assert(nnSite.getPage(page.KindPage, "my-bf-bundle"), qt.Equals, bfBundleNN)
|
||||
c.Assert(nnSite.getPage(kinds.KindPage, "bf/my-bf-bundle/index.nn.md"), qt.Equals, bfBundleNN)
|
||||
c.Assert(nnSite.getPage(kinds.KindPage, "bf/my-bf-bundle"), qt.Equals, bfBundleNN)
|
||||
c.Assert(nnSite.getPage(kinds.KindPage, "my-bf-bundle"), qt.Equals, bfBundleNN)
|
||||
|
||||
// See https://github.com/gohugoio/hugo/issues/4295
|
||||
// Every resource should have its Name prefixed with its base folder.
|
||||
@@ -483,7 +484,7 @@ TheContent.
|
||||
s := b.H.Sites[0]
|
||||
|
||||
c.Assert(len(s.RegularPages()), qt.Equals, 7)
|
||||
a1Bundle := s.getPage(page.KindPage, "symbolic2/a1/index.md")
|
||||
a1Bundle := s.getPage(kinds.KindPage, "symbolic2/a1/index.md")
|
||||
c.Assert(a1Bundle, qt.Not(qt.IsNil))
|
||||
c.Assert(len(a1Bundle.Resources()), qt.Equals, 2)
|
||||
c.Assert(len(a1Bundle.Resources().ByType(pageResourceType)), qt.Equals, 1)
|
||||
@@ -543,10 +544,10 @@ HEADLESS {{< myShort >}}
|
||||
|
||||
c.Assert(len(s.RegularPages()), qt.Equals, 1)
|
||||
|
||||
regular := s.getPage(page.KindPage, "a/index")
|
||||
regular := s.getPage(kinds.KindPage, "a/index")
|
||||
c.Assert(regular.RelPermalink(), qt.Equals, "/s1/")
|
||||
|
||||
headless := s.getPage(page.KindPage, "b/index")
|
||||
headless := s.getPage(kinds.KindPage, "b/index")
|
||||
c.Assert(headless, qt.Not(qt.IsNil))
|
||||
c.Assert(headless.Title(), qt.Equals, "Headless Bundle in Topless Bar")
|
||||
c.Assert(headless.RelPermalink(), qt.Equals, "")
|
||||
|
Reference in New Issue
Block a user