mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-07 20:30:36 -05:00
Fix menu URL for node type pages
By delaying the menu assembly. Fixes #2770
This commit is contained in:
parent
c7f67dd63c
commit
83c6806576
2 changed files with 37 additions and 4 deletions
|
@ -428,6 +428,22 @@ menu:
|
|||
mymenu:
|
||||
name: "Go Home!"
|
||||
---
|
||||
`)
|
||||
|
||||
writeSource(t, filepath.Join("content", "sect1", "_index.md"), `---
|
||||
title: Sect1 With Menu
|
||||
menu:
|
||||
mymenu:
|
||||
name: "Go Sect1!"
|
||||
---
|
||||
`)
|
||||
|
||||
writeSource(t, filepath.Join("content", "categories", "hugo", "_index.md"), `---
|
||||
title: Taxonomy With Menu
|
||||
menu:
|
||||
mymenu:
|
||||
name: "Go Tax Hugo!"
|
||||
---
|
||||
`)
|
||||
|
||||
viper.Set("paginate", 1)
|
||||
|
@ -439,7 +455,9 @@ menu:
|
|||
t.Fatalf("Failed to build site: %s", err)
|
||||
}
|
||||
|
||||
assertFileContent(t, filepath.Join("public", "index.html"), true, "Home With Menu", "Menu Item: Go Home!")
|
||||
assertFileContent(t, filepath.Join("public", "index.html"), true, "Home With Menu", "Home Menu Item: Go Home!: /")
|
||||
assertFileContent(t, filepath.Join("public", "sect1", "index.html"), true, "Sect1 With Menu", "Section Menu Item: Go Sect1!: /sect1/")
|
||||
assertFileContent(t, filepath.Join("public", "categories", "hugo", "index.html"), true, "Taxonomy With Menu", "Taxonomy Menu Item: Go Tax Hugo!: /categories/hugo/")
|
||||
|
||||
}
|
||||
|
||||
|
@ -644,7 +662,7 @@ Index Content: {{ .Content }}
|
|||
{{ end }}
|
||||
{{ with .Site.Menus.mymenu }}
|
||||
{{ range . }}
|
||||
Menu Item: {{ .Name }}
|
||||
Home Menu Item: {{ .Name }}: {{ .URL }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Date: {{ .Date.Format "2006-01-02" }}
|
||||
|
@ -666,6 +684,11 @@ Section Content: {{ .Content }}
|
|||
{{ range .Paginator.Pages }}
|
||||
Pag: {{ .Title }}
|
||||
{{ end }}
|
||||
{{ with .Site.Menus.mymenu }}
|
||||
{{ range . }}
|
||||
Section Menu Item: {{ .Name }}: {{ .URL }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Date: {{ .Date.Format "2006-01-02" }}
|
||||
Lastmod: {{ .Lastmod.Format "2006-01-02" }}
|
||||
`)
|
||||
|
@ -678,6 +701,11 @@ Taxonomy Content: {{ .Content }}
|
|||
{{ range .Paginator.Pages }}
|
||||
Pag: {{ .Title }}
|
||||
{{ end }}
|
||||
{{ with .Site.Menus.mymenu }}
|
||||
{{ range . }}
|
||||
Taxonomy Menu Item: {{ .Name }}: {{ .URL }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Date: {{ .Date.Format "2006-01-02" }}
|
||||
Lastmod: {{ .Lastmod.Format "2006-01-02" }}
|
||||
`)
|
||||
|
@ -689,6 +717,11 @@ Taxonomy Terms Content: {{ .Content }}
|
|||
{{ range $key, $value := .Data.Terms }}
|
||||
k/v: {{ $key }} / {{ printf "%s" $value }}
|
||||
{{ end }}
|
||||
{{ with .Site.Menus.mymenu }}
|
||||
{{ range . }}
|
||||
Taxonomy Terms Menu Item: {{ .Name }}: {{ .URL }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Date: {{ .Date.Format "2006-01-02" }}
|
||||
Lastmod: {{ .Lastmod.Format "2006-01-02" }}
|
||||
`)
|
||||
|
|
|
@ -1328,8 +1328,6 @@ func readCollator(s *Site, results <-chan HandledResult, errs chan<- error) {
|
|||
func (s *Site) buildSiteMeta() (err error) {
|
||||
defer s.timerStep("build Site meta")
|
||||
|
||||
s.assembleMenus()
|
||||
|
||||
if len(s.Pages) == 0 {
|
||||
return
|
||||
}
|
||||
|
@ -1343,6 +1341,8 @@ func (s *Site) buildSiteMeta() (err error) {
|
|||
|
||||
s.assembleSections()
|
||||
|
||||
s.assembleMenus()
|
||||
|
||||
s.Info.LastChange = s.Pages[0].Lastmod
|
||||
|
||||
return
|
||||
|
|
Loading…
Reference in a new issue