Skip to content

Commit

Permalink
Fixes duplicated submenu cases
Browse files Browse the repository at this point in the history
  • Loading branch information
juanpedromoreno committed Sep 27, 2016
1 parent 3e54c79 commit f199ce8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 13 additions & 1 deletion docs/src/main/tut/docs/layouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 (`<Document Title>`, 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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/main/scala/microsites/layouts/DocsLayout.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}"
Expand Down

0 comments on commit f199ce8

Please sign in to comment.