From 9b04c279984cd236c623e8fe52603c9e6ac9d486 Mon Sep 17 00:00:00 2001 From: bep Date: Thu, 11 Dec 2014 05:33:40 +0100 Subject: [PATCH] Revert "Make Urls in menus respect CanonifyUrls" This reverts commit 3ccb3979028aafb3e6cc16d47daa77a1fdea11fa. --- hugolib/menu_test.go | 2 +- hugolib/node.go | 5 +++-- hugolib/page.go | 2 +- hugolib/site.go | 6 ++---- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/hugolib/menu_test.go b/hugolib/menu_test.go index 8a3fd04d3..2336169a2 100644 --- a/hugolib/menu_test.go +++ b/hugolib/menu_test.go @@ -182,7 +182,7 @@ func TestHomeNodeMenu(t *testing.T) { defer resetMenuTestState(ts) home := ts.site.newHomeNode() - homeMenuEntry := &MenuEntry{Name: home.Title, Url: home.Url} + homeMenuEntry := &MenuEntry{Name: home.Title, Url: string(home.Permalink)} for i, this := range []struct { menu string diff --git a/hugolib/node.go b/hugolib/node.go index 1f50e85e3..be4786390 100644 --- a/hugolib/node.go +++ b/hugolib/node.go @@ -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: n.Url} + me := MenuEntry{Name: n.Title, Url: string(n.Permalink)} for _, child := range inme.Children { if me.IsSameResource(child) { @@ -52,7 +52,8 @@ func (n *Node) HasMenuCurrent(menuId string, inme *MenuEntry) bool { func (n *Node) IsMenuCurrent(menuId string, inme *MenuEntry) bool { - me := MenuEntry{Name: n.Title, Url: n.Url} + me := MenuEntry{Name: n.Title, Url: string(n.Permalink)} + if !me.IsSameResource(inme) { return false } diff --git a/hugolib/page.go b/hugolib/page.go index 6e4c887a1..67a6842c1 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -473,7 +473,7 @@ func (page *Page) Menus() PageMenus { ret := PageMenus{} if ms, ok := page.Params["menu"]; ok { - link, _ := page.RelPermalink() + link, _ := page.Permalink() me := MenuEntry{Name: page.LinkTitle(), Weight: page.Weight, Url: link} diff --git a/hugolib/site.go b/hugolib/site.go index d5385081b..b17a19280 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -532,12 +532,10 @@ func (s *Site) getMenusFromConfig() Menus { } menuEntry.MarshallMap(ime) - if strings.HasPrefix(menuEntry.Url, "/") { - // make it match the nodes - menuEntry.Url = s.prepUrl(menuEntry.Url) + // make it absolute so it matches the nodes + menuEntry.Url = s.permalinkStr(menuEntry.Url) } - if ret[name] == nil { ret[name] = &Menu{} }