diff --git a/lib/config.php b/lib/config.php index 3eeb6b0..e180cc2 100644 --- a/lib/config.php +++ b/lib/config.php @@ -25,6 +25,13 @@ 'default_secret' => 1, 'default_permissions' => 255, + ], + 'seo' => [ + 'author' => 'Tím AdlerkaTop', + 'description' => 'Toto je neoficiánla študentská stránka pre Adlerku, kde môžete nájsť plno zaujímavostí.', + 'keywords' => 'adlerka, alderka, studenti, studentska stranka, web, dev, webdev, web dev, skola, zabava', + 'generator' => 'TurboRoute', + 'robots' => 'follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large' ] ]; } diff --git a/lib/page.php b/lib/page.php index a9e8b91..a9eaa3b 100644 --- a/lib/page.php +++ b/lib/page.php @@ -157,12 +157,47 @@ function getPage($site_name_in = null, $page_name_in = null): string $navigation = generateNavigation(); + $seo = array(); + + + if(!empty($pageMetadata["parameters"]["author"])){ + $seo["author"] = htmlspecialchars($pageMetadata["parameters"]["author"]); + } + else{ + $seo["author"] = $routerConfig["seo"]["author"]; + } + + if(!empty($pageMetadata["parameters"]["description"])){ + $seo["description"] = htmlspecialchars($pageMetadata["parameters"]["description"]); + } + else{ + $seo["description"] = $routerConfig["seo"]["description"]; + } + + if(!empty($pageMetadata["parameters"]["keywords"])){ + $seo["keywords"] = $routerConfig["seo"]["keywords"] . ", " . htmlspecialchars($pageMetadata["parameters"]["keywords"]); + } + else{ + $seo["keywords"] = $routerConfig["seo"]["keywords"]; + } + + $seo["generator"] = $routerConfig["seo"]["generator"]; + + $seo["robots"] = $routerConfig["seo"]["robots"]; + + $seo_stuff = ""; + + foreach ($seo as $key => $value){ + $seo_stuff .= "\n"; + } + $out = $skeleton; $out = str_replace("__TEMPLATE__NAV__", $navigation, $out); $out = str_replace("__TEMPLATE__PAGE__", $page, $out); $out = str_replace("__TEMPLATE__FOOTER__", $footer, $out); $out = str_replace("__TEMPLATE__DYNAMIC__SCRIPT__", $dynamic_script, $out); $out = str_replace("__TEMPLATE__DYNAMIC__STYLE__", $dynamic_style, $out); + $out = str_replace("__TEMPLATE_SEO_STUFF__", $seo_stuff, $out); if($routerConfig["inlining"]) { require_once "lib/inliner.php"; $out = inlineLocalStylesFromHref($out); diff --git a/templates/skeleton.html b/templates/skeleton.html index 054136a..daa5b57 100644 --- a/templates/skeleton.html +++ b/templates/skeleton.html @@ -11,6 +11,7 @@