feat(*): refactor dynamic vs. static structure and distinctions; make additional elements dynamic

This commit is contained in:
Cory Dransfeldt 2025-06-13 16:31:36 -07:00
parent 7a0b808f24
commit 203012eef7
No known key found for this signature in database
129 changed files with 983 additions and 960 deletions

View file

@ -0,0 +1,39 @@
<?php
if (!function_exists('setupPageMetadata')) {
function setupPageMetadata(array $page, string $requestUri): array
{
$globals = $page['globals'] ?? [];
$title = htmlspecialchars($page["metadata"]["title"] ?? "", ENT_QUOTES, "UTF-8");
$description = htmlspecialchars($page["metadata"]["description"] ?? "", ENT_QUOTES, "UTF-8");
$image = htmlspecialchars(
$page["metadata"]["open_graph_image"] ?? $globals["metadata"]["open_graph_image"] ?? "",
ENT_QUOTES,
"UTF-8"
);
$fullUrl = $globals["url"] . $requestUri;
$oembedUrl = $globals["url"] . "/oembed" . $requestUri;
return [
'pageTitle' => $title,
'pageDescription' => $description,
'ogImage' => $image,
'fullUrl' => $fullUrl,
'oembedUrl' => $oembedUrl,
'globals' => $globals
];
}
}
if (!function_exists('cleanMeta')) {
function cleanMeta($value)
{
$value = trim($value ?? '');
$value = str_replace(["\r", "\n"], ' ', $value);
$value = preg_replace('/\s+/', ' ', $value);
return htmlspecialchars($value, ENT_QUOTES, 'UTF-8');
}
}
?>