mirror of
https://github.com/gohugoio/hugo.git
synced 2025-04-27 06:00:25 +03: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:
parent
cb7a4339b7
commit
7b7a0f3624
6 changed files with 145 additions and 60 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue