Skip to content
This repository was archived by the owner on Feb 7, 2023. It is now read-only.

Commit 676b26a

Browse files
committed
if a pattern or pattern subtype only contains commented out items don't add to nav
1 parent d1443f0 commit 676b26a

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

builder/lib/builder.lib.php

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ protected function gatherNavItems() {
346346
$b = array("buckets" => array()); // the array that will contain the items
347347
$bi = 0; // track the number for the bucket array
348348
$ni = 0; // track the number for the nav items array
349+
$incrementNavItem = true; // track nav item regeneration so we avoid rebuilding view all pages
349350

350351
// iterate through each pattern type and add them as buckets
351352
foreach($this->patternTypes as $patternType) {
@@ -380,6 +381,12 @@ protected function gatherNavItems() {
380381

381382
}
382383

384+
// if all of the patterns for a given pattern type (e.g. atoms) were commented out we need to unset it
385+
if (!isset($b["buckets"][$bi]["patternItems"])) {
386+
unset($b["buckets"][$bi]);
387+
$bi--;
388+
}
389+
383390
} else {
384391

385392
// iterate over pattern sub-types
@@ -413,6 +420,12 @@ protected function gatherNavItems() {
413420

414421
}
415422

423+
// if all of the patterns for a given sub-type were commented out we need to unset it
424+
if (!isset($b["buckets"][$bi]["navItems"][$ni]["navSubItems"])) {
425+
unset($b["buckets"][$bi]["navItems"][$ni]);
426+
$incrementNavItem = false;
427+
}
428+
416429
}
417430

418431
// add a view all for the section
@@ -428,7 +441,13 @@ protected function gatherNavItems() {
428441
$this->viewAllPaths[$vaBucket][$vaDirFinal] = $patternType."-".$dirClean;
429442
}
430443

431-
$ni++;
444+
// this feels like such a hacky way of doing it
445+
if (!$incrementNavItem) {
446+
$incrementNavItem = true;
447+
} else {
448+
$ni++;
449+
}
450+
432451
}
433452
}
434453

0 commit comments

Comments
 (0)