Remove redundant comments from rendering functions

This commit is contained in:
Ruben 2025-12-12 21:44:55 +01:00
parent 70cb3cb59f
commit 602fbe196f

View file

@ -22,7 +22,6 @@ function renderContentFile(string $filePath, ?Context $ctx = null): string {
}
$html = '<article>' . (new ParsedownExtra())->text(file_get_contents($filePath)) . '</article>';
// Add language prefix to internal links
if ($langPrefix) {
$html = preg_replace(
'/href="(\/[^"]*)"/',
@ -35,7 +34,6 @@ function renderContentFile(string $filePath, ?Context $ctx = null): string {
echo $html;
}
} elseif (in_array($ext, ['html', 'php'])) {
// Make template variables available to PHP content files
if ($ctx !== null && $ext === 'php') {
$templateVars = Hooks::apply(Hook::TEMPLATE_VARS, [], $ctx);
extract($templateVars);
@ -48,12 +46,10 @@ function renderContentFile(string $filePath, ?Context $ctx = null): string {
function renderTemplate(Context $ctx, string $content, int $statusCode = 200): void {
global $GLOBALS;
// Get basic template vars
$navigation = $ctx->navigation;
$homeLabel = $ctx->homeLabel;
$pageTitle = null;
// Let plugins add template variables
$templateVars = Hooks::apply(Hook::TEMPLATE_VARS, [
'content' => $content,
'navigation' => $navigation,
@ -82,7 +78,6 @@ function renderFile(Context $ctx, string $filePath): void {
$pageDir = dirname($realPath);
$pageMetadata = loadMetadata($pageDir);
// Load page-level plugins
getPluginManager()->loadPagePlugins($pageMetadata);
$navigation = $ctx->navigation;
@ -90,12 +85,10 @@ function renderFile(Context $ctx, string $filePath): void {
$pageTitle = $pageMetadata['title'] ?? null;
$metaDescription = extractMetaDescription($pageDir, $pageMetadata);
// Check for page-specific CSS
$pageCss = findPageCss($pageDir, $ctx->contentDir);
$pageCssUrl = $pageCss['url'] ?? null;
$pageCssHash = $pageCss['hash'] ?? null;
// Check for cover image for social media
$coverImage = findCoverImage($pageDir);
$socialImageUrl = null;
if ($coverImage) {
@ -104,7 +97,6 @@ function renderFile(Context $ctx, string $filePath): void {
$socialImageUrl = '/' . ($relativePath ? $relativePath . '/' : '') . $coverImage;
}
// Let plugins add template variables
$templateVars = Hooks::apply(Hook::TEMPLATE_VARS, [
'content' => $content,
'navigation' => $navigation,
@ -118,7 +110,6 @@ function renderFile(Context $ctx, string $filePath): void {
extract($templateVars);
// Wrap content with page template
ob_start();
require $ctx->templates->page;
$wrappedContent = ob_get_clean();
@ -127,7 +118,6 @@ function renderFile(Context $ctx, string $filePath): void {
exit;
}
// Unknown type - 404
renderTemplate($ctx, "<article><h1>404 - Not Found</h1><p>The requested file could not be found.</p></article>", 404);
}
@ -139,7 +129,6 @@ function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void
$pageMetadata = loadMetadata($pageDir);
// Load page-level plugins
getPluginManager()->loadPagePlugins($pageMetadata);
$navigation = $ctx->navigation;
@ -147,12 +136,10 @@ function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void
$pageTitle = $pageMetadata['title'] ?? null;
$metaDescription = extractMetaDescription($pageDir, $pageMetadata);
// Check for page-specific CSS
$pageCss = findPageCss($pageDir, $ctx->contentDir);
$pageCssUrl = $pageCss['url'] ?? null;
$pageCssHash = $pageCss['hash'] ?? null;
// Check for cover image
$coverImage = findCoverImage($pageDir);
$socialImageUrl = null;
if ($coverImage) {
@ -161,7 +148,6 @@ function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void
$socialImageUrl = '/' . ($relativePath ? $relativePath . '/' : '') . $coverImage;
}
// Let plugins add template variables
$templateVars = Hooks::apply(Hook::TEMPLATE_VARS, [
'content' => $content,
'navigation' => $navigation,
@ -175,7 +161,6 @@ function renderMultipleFiles(Context $ctx, array $files, string $pageDir): void
extract($templateVars);
// Wrap content with page template
ob_start();
require $ctx->templates->page;
$wrappedContent = ob_get_clean();