Add meta description support to pages

Add description meta tag to base template Fix navigation list structure
in header Add meta description extraction helper function Update
rendering and routing to include meta description
This commit is contained in:
Ruben 2025-11-03 22:30:49 +01:00
parent 6009cb451e
commit 0b84615bf9
5 changed files with 49 additions and 3 deletions

View file

@ -86,7 +86,7 @@ header {
margin-top: .4rem;
padding: 0;
justify-content: flex-end;
a {
li {
margin-left:0.4rem;
margin-top:0.4rem;
}

View file

@ -17,6 +17,9 @@ function getActiveClass($href) { return rtrim(parse_url($_SERVER['REQUEST_URI'],
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php if (!empty($metaDescription)): ?>
<meta name="description" content="<?= htmlspecialchars($metaDescription) ?>">
<?php endif; ?>
<link rel="stylesheet" href="<?= $cssUrl ?>?v=<?= $cssHash ?>">
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
<link rel="icon" href="/favicon.png" type="image/png">
@ -36,10 +39,10 @@ function getActiveClass($href) { return rtrim(parse_url($_SERVER['REQUEST_URI'],
</div>
<nav>
<ul>
<a href="/" class="button <?php echo getActiveClass('/'); ?>"><li><?= htmlspecialchars($translations['home'] ?? 'Home') ?></li></a>
<li><a href="/" class="button <?php echo getActiveClass('/'); ?>"><?= htmlspecialchars($translations['home'] ?? 'Home') ?></a></li>
<?php if (!empty($navigation)): ?>
<?php foreach ($navigation as $item): ?>
<a href="<?= htmlspecialchars($item['url']) ?>" class="button <?php echo getActiveClass($item['url']); ?>"><li><?= htmlspecialchars($item['title']) ?></li></a>
<li><a href="<?= htmlspecialchars($item['url']) ?>" class="button <?php echo getActiveClass($item['url']); ?>"><?= htmlspecialchars($item['title']) ?></a></li>
<?php endforeach; ?>
<?php endif; ?>
</ul>