mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
IsMenuCurrent now resolving correctly when baseUrl is not at the root path
This commit is contained in:
parent
b4871787f0
commit
2b91b480d0
1 changed files with 13 additions and 0 deletions
|
@ -18,6 +18,7 @@ import (
|
||||||
"html/template"
|
"html/template"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Node struct {
|
type Node struct {
|
||||||
|
@ -56,8 +57,20 @@ func (n *Node) HasMenuCurrent(menuID string, inme *MenuEntry) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (n *Node) IsMenuCurrent(menuID string, inme *MenuEntry) bool {
|
func (n *Node) IsMenuCurrent(menuID string, inme *MenuEntry) bool {
|
||||||
|
s := n.Site
|
||||||
|
|
||||||
me := MenuEntry{Name: n.Title, URL: n.URL}
|
me := MenuEntry{Name: n.Title, URL: n.URL}
|
||||||
|
|
||||||
|
if strings.HasPrefix(me.URL, "/") {
|
||||||
|
// make it match the nodes
|
||||||
|
menuEntryURL := me.URL
|
||||||
|
menuEntryURL = helpers.URLizeAndPrep(menuEntryURL)
|
||||||
|
if !s.canonifyURLs {
|
||||||
|
menuEntryURL = helpers.AddContextRoot(string(s.BaseURL), menuEntryURL)
|
||||||
|
}
|
||||||
|
me.URL = menuEntryURL
|
||||||
|
}
|
||||||
|
|
||||||
if !me.IsSameResource(inme) {
|
if !me.IsSameResource(inme) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue