mirror of
https://github.com/gohugoio/hugo.git
synced 2024-12-28 09:42:19 +00:00
d013edb7f8
Prior to this commit, `HasMenuCurrent` and `IsMenuCurrent` on `Node` always returned false. This made it hard (if possible at all) to mark the currently selected menu item/group for non-Page content (home page, category pages etc.), i.e. for menus defined in the site configuration. This commit provides an implementation of these two methods. Notable design choices: * These menu items have a loose coupling to the the resources they navigate to; the `Url` is the best common identificator. To facilitate a consistent matching, and to get it in line with the menu items connected to `Page`, relative Urls (Urls starting with '/') for menu items in the site configuration are converted to permaLinks using the same rules used for others’. * `IsMenuCurrent` only looks at the children of the current node; this is in line with the implementation on `Page`. * Due to this loose coupling, `IsMenuCurrent` have to search downards in the tree to make sure that the node is inside the current menu. This could have been made simpler if it could answer `yes` to any match of any menu item matching the current resource. This commit also adds a set of unit tests for the menu system. Fixes #367 |
||
---|---|---|
.. | ||
benchmark_test.go | ||
handler_file.go | ||
handler_page.go | ||
handlers.go | ||
menu.go | ||
menu_test.go | ||
node.go | ||
page.go | ||
page_permalink_test.go | ||
page_taxonomy_test.go | ||
page_test.go | ||
page_time_integration_test.go | ||
pageGroup.go | ||
pageSort.go | ||
path_seperators_test.go | ||
path_seperators_windows_test.go | ||
permalinks.go | ||
permalinks_test.go | ||
planner.go | ||
redis.cn.md | ||
rss_test.go | ||
shortcode.go | ||
shortcode_test.go | ||
site.go | ||
site_show_plan_test.go | ||
site_test.go | ||
site_url_test.go | ||
siteinfo_test.go | ||
sitemap.go | ||
sitemap_test.go | ||
summary.go | ||
taxonomy.go | ||
taxonomy_test.go | ||
template.go | ||
template_embedded.go | ||
template_test.go |