mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-14 20:33:59 +02:00
resources/page: Expand parmalinks tokens in url
This change allows to use permalink tokens in url front matter fields. This should be useful to target more specific pages instead of using a global permalink configuration. It's expected to be used with cascade. Fixes #9714
This commit is contained in:
@@ -193,3 +193,42 @@ List.
|
||||
b.AssertFileContent("public/libros/fiction/index.html", "List.")
|
||||
b.AssertFileContent("public/libros/fiction/2023/book1/index.html", "Single.")
|
||||
}
|
||||
|
||||
func TestPermalinksUrlCascade(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
files := `
|
||||
-- layouts/_default/list.html --
|
||||
List|{{ .Kind }}|{{ .RelPermalink }}|
|
||||
-- layouts/_default/single.html --
|
||||
Single|{{ .Kind }}|{{ .RelPermalink }}|
|
||||
-- hugo.toml --
|
||||
-- content/cooking/delicious-recipes/_index.md --
|
||||
---
|
||||
url: /delicious-recipe/
|
||||
cascade:
|
||||
url: /delicious-recipe/:slug/
|
||||
---
|
||||
-- content/cooking/delicious-recipes/example1.md --
|
||||
---
|
||||
title: Recipe 1
|
||||
---
|
||||
-- content/cooking/delicious-recipes/example2.md --
|
||||
---
|
||||
title: Recipe 2
|
||||
slug: custom-recipe-2
|
||||
---
|
||||
`
|
||||
b := hugolib.NewIntegrationTestBuilder(
|
||||
hugolib.IntegrationTestConfig{
|
||||
T: t,
|
||||
TxtarString: files,
|
||||
LogLevel: logg.LevelWarn,
|
||||
}).Build()
|
||||
|
||||
t.Log(b.LogString())
|
||||
b.Assert(b.H.Log.LoggCount(logg.LevelWarn), qt.Equals, 0)
|
||||
b.AssertFileContent("public/delicious-recipe/index.html", "List|section|/delicious-recipe/")
|
||||
b.AssertFileContent("public/delicious-recipe/recipe-1/index.html", "Single|page|/delicious-recipe/recipe-1/")
|
||||
b.AssertFileContent("public/delicious-recipe/custom-recipe-2/index.html", "Single|page|/delicious-recipe/custom-recipe-2/")
|
||||
}
|
||||
|
Reference in New Issue
Block a user