Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9b5f1d4

Browse files
jmooringbep
authored andcommitted
hugolib: Allow regular pages to cascade to self
Closes #14627
1 parent 87f8de8 commit 9b5f1d4

2 files changed

Lines changed: 63 additions & 1 deletion

File tree

hugolib/cascade_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,3 +481,65 @@ title: p1 de
481481
b.AssertFileExists("public/de/s1/p1/index.html", true)
482482
b.AssertFileExists("public/en/s1/p1/index.html", false)
483483
}
484+
485+
// Issue 14627
486+
func TestRegularPageCascadeToSelf(t *testing.T) {
487+
t.Parallel()
488+
489+
files := `
490+
-- hugo.toml --
491+
disableKinds = ['home','rss','sitemap','taxonomy','term']
492+
environment = 'pubweb'
493+
-- content/s1/_index.md --
494+
---
495+
title: s1
496+
cascade:
497+
target:
498+
environment: pubweb
499+
build:
500+
list: never
501+
render: never
502+
publishResources: false
503+
---
504+
-- content/s1/p1.md --
505+
---
506+
title: p1
507+
---
508+
-- content/s2/_index.md --
509+
---
510+
title: s2
511+
---
512+
-- content/s2/p2.md --
513+
---
514+
title: p2
515+
cascade:
516+
target:
517+
environment: pubweb
518+
build:
519+
list: never
520+
render: never
521+
publishResources: false
522+
---
523+
-- content/s2/p3/index.md --
524+
---
525+
title: p3
526+
cascade:
527+
target:
528+
environment: pubweb
529+
build:
530+
list: never
531+
render: never
532+
publishResources: false
533+
---
534+
-- layouts/all.html --
535+
{{ .Title }}|
536+
`
537+
538+
b := Test(t, files)
539+
540+
b.AssertFileExists("public/s1/index.html", false)
541+
b.AssertFileExists("public/s1/p1/index.html", false)
542+
b.AssertFileExists("public/s2/index.html", true)
543+
b.AssertFileExists("public/s2/p2/index.html", false)
544+
b.AssertFileExists("public/s2/p3/index.html", false)
545+
}

hugolib/page__meta.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ func (m *pageMetaSource) doInitEarly(h *HugoSites, cascades *page.PageMatcherPar
204204
return err
205205
}
206206

207-
if cnh.isBranchNode(m) && m.pageConfigSource.Frontmatter != nil {
207+
if m.pageConfigSource.Frontmatter != nil {
208208
if err := m.setCascadeFromMap(m.pageConfigSource.Frontmatter, m.pageConfigSource.SitesMatrix, h.Conf.ConfiguredDimensions(), h.Log); err != nil {
209209
return err
210210
}

0 commit comments

Comments
 (0)