]> BookStack Code Mirror - bookstack/commitdiff
Updated page nav to hide when empty
authorDan Brown <redacted>
Sat, 14 Jan 2017 15:34:52 +0000 (15:34 +0000)
committerDan Brown <redacted>
Sat, 14 Jan 2017 15:34:52 +0000 (15:34 +0000)
app/Repos/EntityRepo.php
resources/views/pages/sidebar-tree-list.blade.php

index 0515a4cd47c06d6ff88f136211241a56a76281d7..83e79ac9b26e3a83f28203b970a3b433c82fe1d4 100644 (file)
@@ -836,18 +836,18 @@ class EntityRepo
     /**
      * Parse the headers on the page to get a navigation menu
      * @param Page $page
-     * @return Collection
+     * @return array
      */
     public function getPageNav(Page $page)
     {
-        if ($page->html == '') return null;
+        if ($page->html == '') return [];
         libxml_use_internal_errors(true);
         $doc = new DOMDocument();
         $doc->loadHTML(mb_convert_encoding($page->html, 'HTML-ENTITIES', 'UTF-8'));
         $xPath = new DOMXPath($doc);
         $headers = $xPath->query("//h1|//h2|//h3|//h4|//h5|//h6");
 
-        if (is_null($headers)) return null;
+        if (is_null($headers)) return [];
 
         $tree = collect([]);
         foreach ($headers as $header) {
@@ -868,7 +868,7 @@ class EntityRepo
                 return $header;
             });
         }
-        return $tree;
+        return $tree->toArray();
     }
 
     /**
index 0fb97369e94480d9eb6e25d3fbcc4034547e2679..f366e9e9b8a29c79a9f6563a4437a98a3a1364ad 100644 (file)
@@ -26,7 +26,7 @@
         @endforeach
     @endif
 
-    @if (isset($pageNav) && $pageNav)
+    @if (isset($pageNav) && count($pageNav))
         <h6 class="text-muted">{{ trans('entities.pages_navigation') }}</h6>
         <div class="sidebar-page-nav menu">
             @foreach($pageNav as $navItem)