Commit graph

6 commits

Author SHA1 Message Date
bep
d013edb7f8 Implement HasMenuCurrent and IsMenuCurrent for Nodes
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
2014-11-01 22:34:49 -04:00
Nate Finch
0099b5a3cb Change all uses of sort.Sort to sort.Stable.Using sort.Stable ensures that even if the sort keys are the same, the order of the sort will not randomly change. Using the old sort.Sort, if you had pages with no date, the lists of those pages would randomly reorder every time you regenerate the list, causing spurious changes to the output. Now they'll always get ordered in the same way. 2014-09-09 09:22:16 -04:00
spf13
57ad3abe7b Pre and Post in Menu are type HTML 2014-05-27 18:34:29 -04:00
spf13
a4a1e39a51 Fixing issue when two menu items have the same name. 2014-05-14 18:08:11 -04:00
spf13
bdf7cd9f9d Creating site menu configuration and have the docs site use it 2014-04-24 16:11:08 -06:00
spf13
9ecf58e29b new menus system including active link & nesting 2014-04-23 02:59:19 -04:00