Added support for index pages

This commit is contained in:
Belle Aerni 2023-01-06 15:17:31 -08:00
parent ba585f7616
commit bb5da2fc50
2 changed files with 10 additions and 2 deletions

View file

@ -39,14 +39,22 @@ class AntCMS
$content .= '<br>';
$content .= "That request caused an exception code ($exceptionCode)";
echo AntMarkdown::renderMarkdown($content);
exit;
}
public function getPage($page)
{
$page = strtolower($page);
$pagePath = AntDir . "/Content/$page.md";
$pagePath = AntDir . "/Content/$page";
$pagePath = str_replace('//', '/', $pagePath);
$AntKeywords = new AntKeywords();
if(is_dir($pagePath)){
$pagePath = $pagePath . '/index.md';
} else {
$pagePath = $pagePath . '.md';
}
if (file_exists($pagePath)) {
try {
$pageContent = file_get_contents($pagePath);

View file

@ -43,7 +43,7 @@ if ($currentConfg['forceHTTPS'] && 'cli' !== PHP_SAPI){
$requestedPage = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);
$indexes = ['/', '/index.php', '/index.html'];
if (in_array($requestedPage, $indexes)) {
$antCms->renderPage('index');
$antCms->renderPage('/');
} else {
$antCms->renderPage($requestedPage);
}