Files
tsv08kulmbach-website/app/components/meta.php

53 lines
2.3 KiB
PHP
Raw Normal View History

<?php
declare(strict_types=1);
/**
* <head>-Inhalt. Props: $meta (array aus der Page), $current (Slug).
* $meta: title, description, og_image (optional, Pfad relativ zu assets/),
* title_absolute (bool Title ohne Suffix), scripts (array zusätzlicher JS-Dateien).
*/
$club = json_load('club');
$title = $meta['title'] ?? $club['name'];
if (empty($meta['title_absolute'])) {
$title .= ' | ' . $club['name'];
}
$description = $meta['description'] ?? $club['description'];
$canonical = abs_url($current === '404' ? '' : $current);
$ogImage = rtrim((string) config('base_url'), '/') . '/assets/' . ltrim($meta['og_image'] ?? 'img/og-default.jpg', '/');
$scripts = array_merge(['nav.js'], $meta['scripts'] ?? []);
?>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= e($title) ?></title>
<meta name="description" content="<?= e($description) ?>">
<?php if ($current !== '404'): ?>
<link rel="canonical" href="<?= e($canonical) ?>">
<?php else: ?>
<meta name="robots" content="noindex">
<?php endif; ?>
<meta name="theme-color" content="#222222">
<meta property="og:type" content="website">
<meta property="og:site_name" content="<?= e($club['name']) ?>">
<meta property="og:title" content="<?= e($title) ?>">
<meta property="og:description" content="<?= e($description) ?>">
<meta property="og:url" content="<?= e($canonical) ?>">
<meta property="og:image" content="<?= e($ogImage) ?>">
<meta property="og:locale" content="de_DE">
<meta name="twitter:card" content="summary_large_image">
<link rel="icon" href="/favicon.ico" sizes="32x32">
<link rel="icon" href="<?= e(asset('img/logo.svg')) ?>" type="image/svg+xml">
<?php foreach (['fonts/coolvetica.woff2', 'fonts/abel.woff2'] as $font): ?>
<?php if (is_file(PUBLIC_PATH . '/assets/' . $font)): ?>
<link rel="preload" href="<?= e(asset($font)) ?>" as="font" type="font/woff2" crossorigin>
<?php endif; ?>
<?php endforeach; ?>
<?php foreach (['tokens', 'reset', 'base', 'layout', 'components', 'utilities'] as $css): ?>
<link rel="stylesheet" href="<?= e(asset("css/{$css}.css")) ?>">
<?php endforeach; ?>
<?php foreach ($scripts as $js): ?>
<script defer src="<?= e(asset("js/{$js}")) ?>"></script>
<?php endforeach; ?>
<?php component('jsonld'); ?>