mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
committed by
Bjørn Erik Pedersen
parent
55ecd3a90e
commit
b3f32949cb
@@ -622,3 +622,79 @@ title: p3
|
|||||||
b.AssertFileExists("public/index.html", true)
|
b.AssertFileExists("public/index.html", true)
|
||||||
b.AssertFileContent("public/index.html", `<a href="/s1/p2/">p2</a><a href="/s1/">s1</a>`)
|
b.AssertFileContent("public/index.html", `<a href="/s1/p2/">p2</a><a href="/s1/">s1</a>`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Issue 13161
|
||||||
|
func TestMenuNameAndTitleFallback(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
disableKinds = ['rss','sitemap','taxonomy','term']
|
||||||
|
[[menus.main]]
|
||||||
|
name = 'P1_ME_Name'
|
||||||
|
title = 'P1_ME_Title'
|
||||||
|
pageRef = '/p1'
|
||||||
|
weight = 10
|
||||||
|
[[menus.main]]
|
||||||
|
pageRef = '/p2'
|
||||||
|
weight = 20
|
||||||
|
[[menus.main]]
|
||||||
|
pageRef = '/p3'
|
||||||
|
weight = 30
|
||||||
|
[[menus.main]]
|
||||||
|
name = 'S1_ME_Name'
|
||||||
|
title = 'S1_ME_Title'
|
||||||
|
pageRef = '/s1'
|
||||||
|
weight = 40
|
||||||
|
[[menus.main]]
|
||||||
|
pageRef = '/s2'
|
||||||
|
weight = 50
|
||||||
|
[[menus.main]]
|
||||||
|
pageRef = '/s3'
|
||||||
|
weight = 60
|
||||||
|
-- content/p1.md --
|
||||||
|
---
|
||||||
|
title: P1_Title
|
||||||
|
---
|
||||||
|
-- content/p2.md --
|
||||||
|
---
|
||||||
|
title: P2_Title
|
||||||
|
---
|
||||||
|
-- content/p3.md --
|
||||||
|
---
|
||||||
|
title: P3_Title
|
||||||
|
linkTitle: P3_LinkTitle
|
||||||
|
---
|
||||||
|
-- content/s1/_index.md --
|
||||||
|
---
|
||||||
|
title: S1_Title
|
||||||
|
---
|
||||||
|
-- content/s2/_index.md --
|
||||||
|
---
|
||||||
|
title: S2_Title
|
||||||
|
---
|
||||||
|
-- content/s3/_index.md --
|
||||||
|
---
|
||||||
|
title: S3_Title
|
||||||
|
linkTitle: S3_LinkTitle
|
||||||
|
---
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
{{ .Content }}
|
||||||
|
-- layouts/_default/list.html --
|
||||||
|
{{ .Content }}
|
||||||
|
-- layouts/_default/home.html --
|
||||||
|
{{- range site.Menus.main }}
|
||||||
|
URL: {{ .URL }}| Name: {{ .Name }}| Title: {{ .Title }}| PageRef: {{ .PageRef }}| Page.Title: {{ .Page.Title }}| Page.LinkTitle: {{ .Page.LinkTitle }}|
|
||||||
|
{{- end }}
|
||||||
|
`
|
||||||
|
|
||||||
|
b := Test(t, files)
|
||||||
|
b.AssertFileContent("public/index.html",
|
||||||
|
`URL: /p1/| Name: P1_ME_Name| Title: P1_ME_Title| PageRef: /p1| Page.Title: P1_Title| Page.LinkTitle: P1_Title|`,
|
||||||
|
`URL: /p2/| Name: P2_Title| Title: P2_Title| PageRef: /p2| Page.Title: P2_Title| Page.LinkTitle: P2_Title|`,
|
||||||
|
`URL: /p3/| Name: P3_LinkTitle| Title: P3_Title| PageRef: /p3| Page.Title: P3_Title| Page.LinkTitle: P3_LinkTitle|`,
|
||||||
|
`URL: /s1/| Name: S1_ME_Name| Title: S1_ME_Title| PageRef: /s1| Page.Title: S1_Title| Page.LinkTitle: S1_Title|`,
|
||||||
|
`URL: /s2/| Name: S2_Title| Title: S2_Title| PageRef: /s2| Page.Title: S2_Title| Page.LinkTitle: S2_Title|`,
|
||||||
|
`URL: /s3/| Name: S3_LinkTitle| Title: S3_Title| PageRef: /s3| Page.Title: S3_Title| Page.LinkTitle: S3_LinkTitle|`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@@ -1224,6 +1224,8 @@ func (s *Site) assembleMenus() error {
|
|||||||
// If page is still nill, we must make sure that we have a URL that considers baseURL etc.
|
// If page is still nill, we must make sure that we have a URL that considers baseURL etc.
|
||||||
if types.IsNil(me.Page) {
|
if types.IsNil(me.Page) {
|
||||||
me.ConfiguredURL = s.createNodeMenuEntryURL(me.MenuConfig.URL)
|
me.ConfiguredURL = s.createNodeMenuEntryURL(me.MenuConfig.URL)
|
||||||
|
} else {
|
||||||
|
navigation.SetPageValues(me, me.Page)
|
||||||
}
|
}
|
||||||
|
|
||||||
flat[twoD{name, me.KeyName()}] = me
|
flat[twoD{name, me.KeyName()}] = me
|
||||||
|
Reference in New Issue
Block a user