mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-15 20:44:01 +02:00
@@ -636,3 +636,43 @@ Menu Item: {{ $i }}|{{ .URL }}|
|
|||||||
Menu Item: 0|/foo/posts|
|
Menu Item: 0|/foo/posts|
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestSectionPagesMenuMultilingualWarningIssue12306(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
disableKinds = ['section','rss','sitemap','taxonomy','term']
|
||||||
|
defaultContentLanguageInSubdir = true
|
||||||
|
sectionPagesMenu = "main"
|
||||||
|
[languages.en]
|
||||||
|
[languages.fr]
|
||||||
|
-- layouts/_default/home.html --
|
||||||
|
{{- range site.Menus.main -}}
|
||||||
|
<a href="{{ .URL }}">{{ .Name }}</a>
|
||||||
|
{{- end -}}
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
{{ .Title }}
|
||||||
|
-- content/p1.en.md --
|
||||||
|
---
|
||||||
|
title: p1
|
||||||
|
menu: main
|
||||||
|
---
|
||||||
|
-- content/p1.fr.md --
|
||||||
|
---
|
||||||
|
title: p1
|
||||||
|
menu: main
|
||||||
|
---
|
||||||
|
-- content/p2.en.md --
|
||||||
|
---
|
||||||
|
title: p2
|
||||||
|
menu: main
|
||||||
|
---
|
||||||
|
`
|
||||||
|
|
||||||
|
b := Test(t, files, TestOptWarn())
|
||||||
|
|
||||||
|
b.AssertFileContent("public/en/index.html", `<a href="/en/p1/">p1</a><a href="/en/p2/">p2</a>`)
|
||||||
|
b.AssertFileContent("public/fr/index.html", `<a href="/fr/p1/">p1</a>`)
|
||||||
|
b.AssertLogNotContains("WARN")
|
||||||
|
}
|
||||||
|
@@ -658,8 +658,13 @@ func (s *Site) assembleMenus() error {
|
|||||||
if p.IsHome() || !p.m.shouldBeCheckedForMenuDefinitions() {
|
if p.IsHome() || !p.m.shouldBeCheckedForMenuDefinitions() {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// The section pages menus are attached to the top level section.
|
// The section pages menus are attached to the top level section.
|
||||||
id := p.Section()
|
id := p.Section()
|
||||||
|
if id == "" {
|
||||||
|
id = "/"
|
||||||
|
}
|
||||||
|
|
||||||
if _, ok := flat[twoD{sectionPagesMenu, id}]; ok {
|
if _, ok := flat[twoD{sectionPagesMenu, id}]; ok {
|
||||||
return false, nil
|
return false, nil
|
||||||
}
|
}
|
||||||
@@ -671,6 +676,7 @@ func (s *Site) assembleMenus() error {
|
|||||||
},
|
},
|
||||||
Page: p,
|
Page: p,
|
||||||
}
|
}
|
||||||
|
|
||||||
navigation.SetPageValues(&me, p)
|
navigation.SetPageValues(&me, p)
|
||||||
flat[twoD{sectionPagesMenu, me.KeyName()}] = &me
|
flat[twoD{sectionPagesMenu, me.KeyName()}] = &me
|
||||||
return false, nil
|
return false, nil
|
||||||
@@ -678,6 +684,7 @@ func (s *Site) assembleMenus() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add menu entries provided by pages
|
// Add menu entries provided by pages
|
||||||
if err := s.pageMap.forEachPage(pagePredicates.ShouldListGlobal, func(p *pageState) (bool, error) {
|
if err := s.pageMap.forEachPage(pagePredicates.ShouldListGlobal, func(p *pageState) (bool, error) {
|
||||||
for name, me := range p.pageMenus.menus() {
|
for name, me := range p.pageMenus.menus() {
|
||||||
|
Reference in New Issue
Block a user