add per page scripts and styles

This commit is contained in:
2024-02-01 09:46:52 +01:00
parent 166ac751c8
commit 76a0568ee2
5 changed files with 65 additions and 32 deletions

View File

@@ -119,12 +119,45 @@ function getPage($page_name = null): array|false|string
$page_title = $page_name;
}
$site_name = $routerRequest["subdomain"];
if(!empty($pageMetadata["parameters"]["page_style"])){
$style_location = $pageMetadata["parameters"]["page_style"];
}
else{
$style_location = "assets/styles/$site_name/$page_name.css";
}
if(file_exists($style_location)) {
$style_tag = $style_location;
}
else{
$style_tag = "";
}
if(!empty($pageMetadata["parameters"]["page_script"])){
$script_location = $pageMetadata["parameters"]["page_script"];
}
else{
$script_location = "assets/scripts/$site_name/$page_name.js";
}
if(file_exists($style_location)) {
$script_tag = $script_location;
}
else{
$script_tag = "";
}
$navpages = generateNavigation();
$nav = str_replace("__NAV_PAGES__", $navpages, $nav);
$out = $skeleton;
$out = str_replace("__TEMPLATE__NAV__", $nav, $out);
$out = str_replace("__TEMPLATE_PAGE_STYLE_TAG__", $style_tag, $out);
$out = str_replace("__TEMPLATE_PAGE_SCRIPT_TAG__", $script_tag, $out);
$out = str_replace("__TEMPLATE__PAGE__", $page, $out);
return str_replace("__TEMPLATE_PAGE_TITLE__", $page_title, $out);
}