mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-19 21:21:39 +02:00
resources/page: Revise the new contentbasename permalinks tokens
* Make it work for all pages, including those created from content adapters and not backed by a file. * Allow the `slug` to win, so the new tokens are: `:contentbasename`: 1. ContentBaseName `:slugorcontentbasename`: 1. Slug 2. ContentBaseName Note that a page will always have a `ContentBaseName`, so no need to fall back to e.g. the title. Closes #11722
This commit is contained in:
@@ -52,7 +52,7 @@ func newTestPage() *testPage {
|
||||
|
||||
func newTestPageWithFile(filename string) *testPage {
|
||||
filename = filepath.FromSlash(filename)
|
||||
file := source.NewFileInfoFrom(filename, filename)
|
||||
file := source.NewContentFileInfoFrom(filename, filename)
|
||||
|
||||
l, err := langs.NewLanguage(
|
||||
"en",
|
||||
@@ -67,9 +67,10 @@ func newTestPageWithFile(filename string) *testPage {
|
||||
}
|
||||
|
||||
return &testPage{
|
||||
params: make(map[string]any),
|
||||
data: make(map[string]any),
|
||||
file: file,
|
||||
params: make(map[string]any),
|
||||
data: make(map[string]any),
|
||||
file: file,
|
||||
pathInfo: file.FileInfo().Meta().PathInfo,
|
||||
currentSection: &testPage{
|
||||
sectionEntries: []string{"a", "b", "c"},
|
||||
},
|
||||
@@ -90,7 +91,8 @@ type testPage struct {
|
||||
|
||||
fuzzyWordCount int
|
||||
|
||||
path string
|
||||
path string
|
||||
pathInfo *paths.Path
|
||||
|
||||
slug string
|
||||
|
||||
@@ -406,7 +408,7 @@ func (p *testPage) Path() string {
|
||||
}
|
||||
|
||||
func (p *testPage) PathInfo() *paths.Path {
|
||||
panic("testpage: not implemented")
|
||||
return p.pathInfo
|
||||
}
|
||||
|
||||
func (p *testPage) Permalink() string {
|
||||
|
Reference in New Issue
Block a user