Improve the way the pagelist is generated
Now it automatically strips off the .md extension since it's unneeded, and it sorts it so that the 'index' of the site is always the first item in the array, since that dictates the order they appear in the browser
This commit is contained in:
parent
f388c99647
commit
02e4492ecd
1 changed files with 14 additions and 2 deletions
|
@ -21,15 +21,27 @@ class AntPages
|
||||||
$page = AntTools::repairFilePath($page);
|
$page = AntTools::repairFilePath($page);
|
||||||
$pageContent = file_get_contents($page);
|
$pageContent = file_get_contents($page);
|
||||||
$pageHeader = AntCMS::getPageHeaders($pageContent);
|
$pageHeader = AntCMS::getPageHeaders($pageContent);
|
||||||
$pageFunctionalPath = str_replace(antContentPath, "", $page);
|
|
||||||
|
// Because we are only getting a list of files with the 'md' extension, we can blindly strip off the extension from each path.
|
||||||
|
// Doing this creates more profesional URLs as AntCMS will automatically add the 'md' extenstion during the page rendering process.
|
||||||
|
$pageFunctionalPath = substr(str_replace(antContentPath, "", $page), 0, -3);
|
||||||
|
|
||||||
|
if ($pageFunctionalPath == '/index') {
|
||||||
|
$pageFunctionalPath = '/';
|
||||||
|
}
|
||||||
|
|
||||||
$currentPage = array(
|
$currentPage = array(
|
||||||
'pageTitle' => $pageHeader['title'],
|
'pageTitle' => $pageHeader['title'],
|
||||||
'fullPagePath' => $page,
|
'fullPagePath' => $page,
|
||||||
'functionalPagePath' => $pageFunctionalPath,
|
'functionalPagePath' => $pageFunctionalPath,
|
||||||
'showInNav' => true,
|
'showInNav' => true,
|
||||||
);
|
);
|
||||||
|
if ($pageFunctionalPath === '/') {
|
||||||
|
array_unshift($pageList, $currentPage);
|
||||||
|
} else {
|
||||||
$pageList[] = $currentPage;
|
$pageList[] = $currentPage;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
AntYaml::saveFile(antPagesList, $pageList);
|
AntYaml::saveFile(antPagesList, $pageList);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue