Browse Source

Améliorer la navigation en ne mettant qu’une entrée s’il y a 1 seul sous-élément, et trier les éléments par ordre alpha.

master
Matthieu Marcillaud 1 year ago
parent
commit
cd89946fa4
  1. 21
      phpdoc/template/components/menu.html.twig
  2. 4
      phpdoc/template/components/sidebar_origin.html.twig

21
phpdoc/template/components/menu.html.twig vendored

@ -0,0 +1,21 @@
{% if depth == 1 %}
<h4 class="phpdocumentor-sidebar__root-namespace">
<a href="{{ entry.url }}" class="{{ destinationPath|trim('/', 'left') == entry.url ? '-active' }}">{{ entry.title | shortFQSEN }}</a>
{% if entry.children.count == 1 %}
{% set entry = entry.children|first %}
<span class="phpdocumentor-sidebar__root-separator">/</span>
<a href="{{ entry.url }}" class="{{ destinationPath|trim('/', 'left') == entry.url ? '-active' }}">{{ entry.title | shortFQSEN }}</a>
{% endif %}
</h4>
{% endif %}
{% if entry.children.count > 0 %}
<ul class="phpdocumentor-list">
{% for child in entry.children|sort((a, b) => a.title|lower <=> b.title|lower) %}
<li>
<a href="{{ child.url }}" class="{{ destinationPath|trim('/', 'left') == child.url ? '-active' }}">{{ child.title | shortFQSEN }}</a>
{{ toc(child, 'components/menu.html.twig', maxDepth, depth) }}
</li>
{% endfor %}
</ul>
{% endif %}

4
phpdoc/template/components/sidebar_origin.html.twig vendored

@ -9,8 +9,8 @@
{% for toc in version.tableOfContents %}
<section class="phpdocumentor-sidebar__category">
<h2 class="phpdocumentor-sidebar__category-header">{{ toc.name }}</h2>
{% for root in toc.roots %}
{{ toc(root, 'components/menu.html.twig', 2) }}
{% for root in toc.roots|sort((a, b) => a.title|lower <=> b.title|lower) %}
{{ toc(root, 'components/menu.html.twig', 1) }}
{% endfor %}
</section>
{% endfor %}

Loading…
Cancel
Save