$pageHeader['title'], 'fullPagePath' => $page, 'functionalPagePath' => $pageFunctionalPath, 'showInNav' => true, ); // Move the index page to the first item in the page list, so it appears as the first item in the navbar. if ($pageFunctionalPath === '/') { array_unshift($pageList, $currentPage); } else { $pageList[] = $currentPage; } } AntYaml::saveFile(antPagesList, $pageList); } /** @return array */ public static function getPages() { return AntYaml::parseFile(antPagesList); } /** * @param string $navTemplate * @param string $currentPage optional - What page is the active page. Used for highlighting the active page in the navbar * @return string */ public static function generateNavigation(string $navTemplate = '', string $currentPage = '') { $pages = AntPages::getPages(); $antCache = new AntCache; $theme = AntConfig::currentConfig('activeTheme'); $cacheKey = $antCache->createCacheKey(json_encode($pages), $theme . $currentPage); if ($antCache->isCached($cacheKey)) { $cachedContent = $antCache->getCache($cacheKey); if ($cachedContent !== false && !empty($cachedContent)) { return $cachedContent; } } $currentPage = strtolower($currentPage); if (str_ends_with($currentPage, '/')) { $currentPage .= 'index.md'; } $baseURL = AntConfig::currentConfig('baseURL'); foreach ($pages as $key => $page) { $url = "//" . AntTools::repairURL($baseURL . $page['functionalPagePath']); $pages[$key]['url'] = $url; $pages[$key]['active'] = $currentPage === strtolower($page['functionalPagePath']); //Remove pages that are hidden from the nav from the array before sending it to twig. if (!(bool)$page['showInNav']) { unset($pages[$key]); } } $navHTML = AntTwig::renderWithTiwg($navTemplate, array('pages' => $pages)); $antCache->setCache($cacheKey, $navHTML); return $navHTML; } }