mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
parent
e6541c45ab
commit
3ccb397902
4 changed files with 8 additions and 7 deletions
|
@ -182,7 +182,7 @@ func TestHomeNodeMenu(t *testing.T) {
|
|||
defer resetMenuTestState(ts)
|
||||
|
||||
home := ts.site.newHomeNode()
|
||||
homeMenuEntry := &MenuEntry{Name: home.Title, Url: string(home.Permalink)}
|
||||
homeMenuEntry := &MenuEntry{Name: home.Title, Url: home.Url}
|
||||
|
||||
for i, this := range []struct {
|
||||
menu string
|
||||
|
|
|
@ -38,7 +38,7 @@ func (n *Node) Now() time.Time {
|
|||
|
||||
func (n *Node) HasMenuCurrent(menuId string, inme *MenuEntry) bool {
|
||||
if inme.HasChildren() {
|
||||
me := MenuEntry{Name: n.Title, Url: string(n.Permalink)}
|
||||
me := MenuEntry{Name: n.Title, Url: n.Url}
|
||||
|
||||
for _, child := range inme.Children {
|
||||
if me.IsSameResource(child) {
|
||||
|
@ -52,8 +52,7 @@ func (n *Node) HasMenuCurrent(menuId string, inme *MenuEntry) bool {
|
|||
|
||||
func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool {
|
||||
|
||||
me := MenuEntry{Name: n.Title, Url: string(n.Permalink)}
|
||||
|
||||
me := MenuEntry{Name: n.Title, Url: n.Url}
|
||||
if !me.IsSameResource(inme) {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -473,7 +473,7 @@ func (page *Page) Menus() PageMenus {
|
|||
ret := PageMenus{}
|
||||
|
||||
if ms, ok := page.Params["menu"]; ok {
|
||||
link, _ := page.Permalink()
|
||||
link, _ := page.RelPermalink()
|
||||
|
||||
me := MenuEntry{Name: page.LinkTitle(), Weight: page.Weight, Url: link}
|
||||
|
||||
|
|
|
@ -532,10 +532,12 @@ func (s *Site) getMenusFromConfig() Menus {
|
|||
}
|
||||
|
||||
menuEntry.MarshallMap(ime)
|
||||
|
||||
if strings.HasPrefix(menuEntry.Url, "/") {
|
||||
// make it absolute so it matches the nodes
|
||||
menuEntry.Url = s.permalinkStr(menuEntry.Url)
|
||||
// make it match the nodes
|
||||
menuEntry.Url = s.prepUrl(menuEntry.Url)
|
||||
}
|
||||
|
||||
if ret[name] == nil {
|
||||
ret[name] = &Menu{}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue