From 93fce9c9f0acfc47353eaa6392458e3856b2fed3 Mon Sep 17 00:00:00 2001 From: Juan Pedro Moreno Date: Tue, 27 Sep 2016 17:15:12 +0200 Subject: [PATCH] Fix duplicated submenu cases --- docs/src/main/tut/docs/layouts.md | 14 +++++++++++++- src/main/scala/microsites/layouts/DocsLayout.scala | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/docs/src/main/tut/docs/layouts.md b/docs/src/main/tut/docs/layouts.md index 8c668dec..8bb14905 100644 --- a/docs/src/main/tut/docs/layouts.md +++ b/docs/src/main/tut/docs/layouts.md @@ -67,12 +67,14 @@ Looking at the [Configuring the Microsite](settings.html) section, in the direct options: - title: Getting Started url: index.html + section: intro - title: Configuring the Microsite url: settings.html - title: Layouts url: layouts.html + section: resources - title: Customize url: customize.html @@ -84,12 +86,14 @@ options: * The `options` key is mandatory. It'll be the parent of all the options defined here. Each `option` or menu item will contain: * `title`: the menu title. It should be the same as defined in the meta-property associated with the file (``, where the layout is defined). * `url`: relative path to the documentation file. +* `section`: this key is mandatory only when you have a nested submenu. It'll be useful to distinguish between sub-items with the same name in different menu options. * Optionally, we could define a second level of nested sub-items, thanks to the `nested_options` key, defined at the same level that `title` and `url` of the parent menu. For example: ``` options: - title: Introduction url: index.html + section: intro nested_options: - title: Submenu 1 @@ -101,7 +105,15 @@ options: url: settings.html ``` -In this example, `Submenu 1` and `Submenu 2` will be nested under the `Introduction` menu option. +In this example, `Submenu 1` and `Submenu 2` will be nested under the `Introduction` menu option. At the same time, `submenu1` and `submenu2` would have the same section name as the parent. For instance, `submenu1.md` would have a header like this, where the `section` field matches the one defined in `menu.yml`: + +``` +--- +layout: docs +title: "Submenu 2" +section: "intro" +--- +``` ## Page Layout and Menu Partial Layout diff --git a/src/main/scala/microsites/layouts/DocsLayout.scala b/src/main/scala/microsites/layouts/DocsLayout.scala index 37d1f6d4..34517ffa 100644 --- a/src/main/scala/microsites/layouts/DocsLayout.scala +++ b/src/main/scala/microsites/layouts/DocsLayout.scala @@ -90,7 +90,7 @@ class DocsLayout(config: MicrositeSettings) extends Layout(config) { "{% if x.nested_options %} ", ul(cls := "sub_section", "{% for sub in x.nested_options %} ", - li(a(href := s"$baseUrl{{sub.url}}", cls := "{% if sub.title == page.title %} active {% endif %}", "{{sub.title}}")), + li(a(href := s"$baseUrl{{sub.url}}", cls := "{% if sub.title == page.title and x.section == page.section %} active {% endif %}", "{{sub.title}}")), "{% endfor %}" ), "{% endif %} {% endfor %}"