-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from loic425/fix/active-menu
Fix active menu detection
- Loading branch information
Showing
3 changed files
with
6 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{% import '@MobizelMarkdownDocs/macro/menu.html.twig' as menu %} | ||
|
||
<ul class="nav flex-column"> | ||
{{ render(path('mobizel_markdown_docs_menu', {'current_item': app.request.requestUri})) }} | ||
{{ render(path('mobizel_markdown_docs_menu', {'current_item': app.request.get('slug')})) }} | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
{% macro nav_item(title, path, current_item) %} | ||
{% set current = (path in current_item) %} | ||
{% macro nav_item(slug, path, current_item) %} | ||
{% set root = current_item|split('/')|first %} | ||
{% set current = (slug == root) %} | ||
<li class="nav-item"> | ||
<a class="nav-link {% if current %}active{% endif %}" href="{{ path }}"> | ||
{{ title }} {% if current %}<span class="sr-only">(current)</span>{% endif %} | ||
{{ page_title(slug) }} {% if current %}<span class="sr-only">(current)</span>{% endif %} | ||
</a> | ||
</li> | ||
{% endmacro %} |