Add page-specific CSS support

Add helper function to find page-specific CSS files Add CSS loading to
base template Update rendering functions to include page CSS Update
router to include page CSS for static pages
This commit is contained in:
Ruben 2025-11-03 23:04:16 +01:00
parent 0b84615bf9
commit 6879fad5fb
7 changed files with 110 additions and 0 deletions

View file

@ -58,6 +58,11 @@ function renderFile(Context $ctx, string $filePath): void {
$pageMetadata = loadMetadata($pageDir, $ctx->currentLang, $ctx->defaultLang);
$pageTitle = $pageMetadata['title'] ?? null;
$metaDescription = extractMetaDescription($pageDir, $pageMetadata, $ctx->currentLang, $ctx->defaultLang);
// Check for page-specific CSS
$pageCss = findPageCss($pageDir, $ctx->contentDir);
$pageCssUrl = $pageCss['url'] ?? null;
$pageCssHash = $pageCss['hash'] ?? null;
// Wrap content with page template
ob_start();
@ -96,6 +101,11 @@ function renderMultipleFiles(Context $ctx, array $filePaths, string $pageDir): v
$pageMetadata = loadMetadata($pageDir, $ctx->currentLang, $ctx->defaultLang);
$pageTitle = $pageMetadata['title'] ?? null;
$metaDescription = extractMetaDescription($pageDir, $pageMetadata, $ctx->currentLang, $ctx->defaultLang);
// Check for page-specific CSS
$pageCss = findPageCss($pageDir, $ctx->contentDir);
$pageCssUrl = $pageCss['url'] ?? null;
$pageCssHash = $pageCss['hash'] ?? null;
// Wrap content with page template
ob_start();