mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-26 22:04:32 +02:00
@@ -671,3 +671,32 @@ S1|p1:|p2:p2|
|
||||
`)
|
||||
})
|
||||
}
|
||||
|
||||
// Issue 11977.
|
||||
func TestCascadeExtensionInPath(t *testing.T) {
|
||||
files := `
|
||||
-- hugo.toml --
|
||||
baseURL = "https://example.org"
|
||||
[languages]
|
||||
[languages.en]
|
||||
weight = 1
|
||||
[languages.de]
|
||||
-- content/_index.de.md --
|
||||
+++
|
||||
[[cascade]]
|
||||
[cascade.params]
|
||||
foo = 'bar'
|
||||
[cascade._target]
|
||||
path = '/posts/post-1.de.md'
|
||||
+++
|
||||
-- content/posts/post-1.de.md --
|
||||
---
|
||||
title: "Post 1"
|
||||
---
|
||||
-- layouts/_default/single.html --
|
||||
{{ .Title }}|{{ .Params.foo }}$
|
||||
`
|
||||
b, err := TestE(t, files)
|
||||
b.Assert(err, qt.IsNotNil)
|
||||
b.AssertLogContains(`cascade target path "/posts/post-1.de.md" looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/`)
|
||||
}
|
||||
|
@@ -33,6 +33,7 @@ import (
|
||||
|
||||
"github.com/gohugoio/hugo/common/constants"
|
||||
"github.com/gohugoio/hugo/common/hugo"
|
||||
"github.com/gohugoio/hugo/common/loggers"
|
||||
"github.com/gohugoio/hugo/common/maps"
|
||||
"github.com/gohugoio/hugo/common/paths"
|
||||
"github.com/gohugoio/hugo/config"
|
||||
@@ -272,7 +273,7 @@ func (p *pageMeta) Weight() int {
|
||||
return p.pageConfig.Weight
|
||||
}
|
||||
|
||||
func (p *pageMeta) setMetaPre(pi *contentParseInfo, conf config.AllProvider) error {
|
||||
func (p *pageMeta) setMetaPre(pi *contentParseInfo, logger loggers.Logger, conf config.AllProvider) error {
|
||||
frontmatter := pi.frontMatter
|
||||
if frontmatter != nil {
|
||||
pcfg := p.pageConfig
|
||||
@@ -285,7 +286,7 @@ func (p *pageMeta) setMetaPre(pi *contentParseInfo, conf config.AllProvider) err
|
||||
// Check for any cascade define on itself.
|
||||
if cv, found := frontmatter["cascade"]; found {
|
||||
var err error
|
||||
cascade, err := page.DecodeCascade(cv)
|
||||
cascade, err := page.DecodeCascade(logger, cv)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -437,7 +438,6 @@ func (p *pageState) setMetaPostParams() error {
|
||||
}
|
||||
pm.pageConfig.Build, err = pagemeta.DecodeBuildConfig(buildConfig)
|
||||
if err != nil {
|
||||
//lint:ignore ST1005 end user message.
|
||||
var msgDetail string
|
||||
if isNewBuildKeyword {
|
||||
msgDetail = `. We renamed the _build keyword to build in Hugo 0.123.0. We recommend putting user defined params in the params section, e.g.:
|
||||
|
@@ -56,7 +56,7 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
if err := m.setMetaPre(pi, h.Conf); err != nil {
|
||||
if err := m.setMetaPre(pi, h.Log, h.Conf); err != nil {
|
||||
return nil, nil, m.wrapError(err, h.BaseFs.SourceFs)
|
||||
}
|
||||
pcfg := m.pageConfig
|
||||
|
Reference in New Issue
Block a user