Change the page endpoint

This commit is contained in:
Bruno Rybársky 2024-02-05 21:37:42 +01:00
parent 01fd8389ac
commit 914057680d

@ -32,7 +32,7 @@ function parsePageTag($input): array
return ['parameters' => [], 'output' => $input];
}
function getPage($page_name = null, $site_name = null): string
function renderPage($page_name = null, $site_name = null): array
{
global $routerConfig;
global $routerRequest;
@ -48,9 +48,6 @@ function getPage($page_name = null, $site_name = null): string
$dynamic_page_file = $routerConfig["page_dir"] . $site_name . "/" . $page_name . ".php";
$page_file = $routerConfig["page_dir"] . $site_name . "/" . $page_name . ".html";
$skeleton = file_get_contents($routerConfig["template_dir"] . "skeleton.html");
$nav = file_get_contents($routerConfig["template_dir"] . "nav.html");
if (file_exists($dynamic_page_file)){
$pageMetadata = renderDynamicPage($dynamic_page_file);
@ -112,15 +109,31 @@ function getPage($page_name = null, $site_name = null): string
$page = "";
}
return [
"PageContent" => $page,
"PageName" => $page_name,
"SiteName" => $site_name,
];
}
function getPage($page_name_in = null, $site_name_in = null): string
{
$page_tmp = renderPage($page_name_in, $site_name_in);
$page = $page_tmp["PageContent"];
$page_name = $page_tmp["PageName"];
$site_name = $page_tmp["SiteName"];
global $routerConfig;
$skeleton = file_get_contents($routerConfig["template_dir"] . "skeleton.html");
$nav = file_get_contents($routerConfig["template_dir"] . "nav.html");
if(!empty($pageMetadata["parameters"]["page_title"])){
$page_title = $pageMetadata["parameters"]["page_title"];
}
else{
$page_title = $page_name;
}
$dynamic_style = doDynamicStyling();
$dynamic_script = generateScriptData([
"currentPage" => $page_name,
@ -146,9 +159,10 @@ function getPageEndpoint($page_name, $site_name) :array
{
global $routerRequest, $routerConfig;
$page_location = $routerConfig["protocol"] . $site_name . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $page_name;
$page_tmp = renderPage($page_name, $site_name);
return [
"Status" => "Success",
"Page" => getPage($page_name, $site_name),
"Page" => $page_tmp["PageContent"],
"PageLocation" => $page_location,
];
}