Skip to content

Commit

Permalink
[BUGFIX] Correct Menu levels in global menu tree
Browse files Browse the repository at this point in the history
Resolves #803
  • Loading branch information
linawolf committed Jan 14, 2024
1 parent 6f9742e commit 8fe3a34
Show file tree
Hide file tree
Showing 21 changed files with 52 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{% if node.caption %}
<h2>{{ renderNode(node.caption) }}</h2>
{% endif %}
<ul class="level-1">
<ul class="menu-level-main">
{% for entry in node.menuEntries -%}
<li><a href="{{ renderLink(entry.url) }}"
class="nav-link {%- if node.currentPath == entry.url %} current {%- endif -%}{% if entry.url in node.rootlinePaths %} active {%- endif -%}"
Expand Down
6 changes: 3 additions & 3 deletions packages/guides/src/Compiler/Passes/GlobalMenuPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ private function getMenuEntryWithChildren(CompilerContext $compilerContext, Menu
return $menuEntry;
}

$newMenuEntry = new InternalMenuEntryNode($menuEntry->getUrl(), $menuEntry->getValue(), [], false, 2);
$newMenuEntry = new InternalMenuEntryNode($menuEntry->getUrl(), $menuEntry->getValue(), [], false, 1);
$maxdepth = $this->settingsManager->getProjectSettings()->getMaxMenuDepth();
$maxdepth = $maxdepth < 1 ? PHP_INT_MAX : $maxdepth + 1;
$documentEntryOfMenuEntry = $compilerContext->getProjectNode()->getDocumentEntry($menuEntry->getUrl());
$this->addSubEntries($compilerContext, $newMenuEntry, $documentEntryOfMenuEntry, 3, $maxdepth);
$this->addSubEntries($compilerContext, $newMenuEntry, $documentEntryOfMenuEntry, 2, $maxdepth);

return $newMenuEntry;
}
Expand All @@ -113,7 +113,7 @@ private function addSubEntries(
int $currentLevel,
int $maxDepth,
): void {
if ($maxDepth < $currentLevel) {
if ($maxDepth <= $currentLevel) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="#"
class="nav-link current active" aria-current="page" >
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link">
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="subpages/subpage1.html"
class="nav-link">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="yetAnotherPage.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="anotherPage.html"
class="nav-link">
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link">
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="subpages/subpage1.html"
class="nav-link">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="yetAnotherPage.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="anotherPage.html"
class="nav-link">
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link">
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="subpages/subpage1.html"
class="nav-link">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="yetAnotherPage.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="../anotherPage.html"
class="nav-link">
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link current active" aria-current="page" >
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="subpage1.html"
class="nav-link">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="../yetAnotherPage.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="../anotherPage.html"
class="nav-link">
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link active">
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="#"
class="nav-link current active" aria-current="page">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="../yetAnotherPage.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="../anotherPage.html"
class="nav-link">
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link active">
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="subpage1.html"
class="nav-link">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="../yetAnotherPage.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Main Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="anotherPage.html"
class="nav-link">
Another Page
Expand All @@ -79,7 +79,7 @@ <h2>Main Menu</h2>
class="nav-link">
Subpages
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="subpages/subpage1.html"
class="nav-link">
Subpages 1
Expand All @@ -95,7 +95,7 @@ <h2>Main Menu</h2>
</nav>
<nav class="nav flex-column">
<h2>Additional Menu</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="#"
class="nav-link current active" aria-current="page" >
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="/anotherPage.html"
class="nav-link current active" aria-current="page" >
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="/anotherPage.html"
class="nav-link">
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="/anotherPage.html"
class="nav-link">
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="someDirectory/index.html"
class="nav-link">
Some Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="someDirectory/index.html"
class="nav-link">
Some Page
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="someDirectory/anotherDirectory/index.html"
class="nav-link">
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="someDirectory/index.html"
class="nav-link">
Some Page
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="someDirectory/anotherDirectory/index.html"
class="nav-link">
Another Page
</a>
<ul class="level-3">
<ul class="level-2">
<li><a href="someDirectory/anotherDirectory/yetAnotherDirectory/index.html"
class="nav-link">
Yet Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,22 +44,22 @@
<div class="row">
<div class="col-lg-3">
<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="someDirectory/index.html"
class="nav-link">
Some Page
</a>
<ul class="level-2">
<ul class="level-1">
<li><a href="someDirectory/anotherDirectory/index.html"
class="nav-link">
Another Page
</a>
<ul class="level-3">
<ul class="level-2">
<li><a href="someDirectory/anotherDirectory/yetAnotherDirectory/index.html"
class="nav-link">
Yet Another Page
</a>
<ul class="level-4">
<ul class="level-3">
<li><a href="someDirectory/anotherDirectory/yetAnotherDirectory/andYetAnotherDirectory/index.html"
class="nav-link">
And Yet Another Page
Expand Down Expand Up @@ -93,7 +93,16 @@ <h1>Document Title</h1>
<p>Lorem Ipsum Dolor.</p>
<div class="toc">
<ul class="menu-level">
<li class="toc-item"><a href="someDirectory/index.html#some-page">Some Page</a></li>
<li class="toc-item"><a href="someDirectory/index.html#some-page">Some Page</a> <ul class="menu-level-1">
<li class="toc-item"><a href="someDirectory/anotherDirectory/index.html#another-page">Another Page</a> <ul class="menu-level-2">
<li class="toc-item"><a href="someDirectory/anotherDirectory/yetAnotherDirectory/index.html#yet-another-page">Yet Another Page</a> <ul class="menu-level-3">
<li class="toc-item"><a href="someDirectory/anotherDirectory/yetAnotherDirectory/andYetAnotherDirectory/index.html#and-yet-another-page">And Yet Another Page</a></li>

</ul></li>

</ul></li>

</ul></li>

</ul>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@ Lorem Ipsum Dolor.
.. toctree::
:glob:
:titlesonly:
:maxdepth: 1

*/index
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="rubric">Main Menu</div>

<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="/anotherPage.html"
class="nav-link">
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="rubric">Main Menu</div>

<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="/anotherPage.html"
class="nav-link">
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="rubric">Main Menu</div>

<nav class="nav flex-column">
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="/anotherPage.html"
class="nav-link">
Another Page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<div class="col-lg-3">
<nav class="nav flex-column">
<h2>Some Caption</h2>
<ul class="level-1">
<ul class="menu-level-main">
<li><a href="https://example.com/index.html#debug-settings"
class="nav-link">
Title
Expand Down

0 comments on commit 8fe3a34

Please sign in to comment.