Add page CSS URL and hash to template variables

Move page CSS handling from rendering to router
This commit is contained in:
Ruben 2026-02-05 23:30:20 +01:00
parent 7782eefa96
commit 696b0ad801
2 changed files with 4 additions and 61 deletions

View file

@ -110,9 +110,6 @@ switch ($parsedPath['type']) {
$listTemplate = $ctx->templates->list;
if (isset($metadata['page_template']) && !empty($metadata['page_template'])) {
$templateName = $metadata['page_template'];
if (!str_ends_with($templateName, '.php')) {
$templateName .= '';
}
$customTemplate = dirname(__DIR__) . "/custom/templates/$templateName.php";
$defaultTemplate = __DIR__ . "/default/templates/$templateName.php";
@ -186,6 +183,8 @@ switch ($parsedPath['type']) {
// Check for page-specific CSS
$pageCss = findPageCss($dir, $ctx->contentDir);
$pageCssUrl = $pageCss['url'] ?? null;
$pageCssHash = $pageCss['hash'] ?? null;
// Let plugins add template variables
$templateVars = Hooks::apply(Hook::TEMPLATE_VARS, [
@ -193,7 +192,8 @@ switch ($parsedPath['type']) {
'homeLabel' => $homeLabel,
'pageTitle' => $pageTitle,
'metaDescription' => $metaDescription,
'pageCss' => $pageCss,
'pageCssUrl' => $pageCssUrl,
'pageCssHash' => $pageCssHash,
'items' => $items,
'pageContent' => $pageContent
], $ctx);