145 lines
4.6 KiB
PHP
145 lines
4.6 KiB
PHP
<?php
|
||
// public/partials/layout_start.php
|
||
|
||
// Erwartet (vor require):
|
||
// - $lang (de|en|it|fr) – bereits validiert
|
||
// - $pageTitle (string)
|
||
// - $pageDescription (string, optional)
|
||
// - $userInitials (optional, kann null sein)
|
||
// - optional: $canonical (string) → überschreibt die automatisch berechnete Canonical-URL
|
||
|
||
// Fallbacks:
|
||
if (!isset($lang) || !in_array($lang, ['de', 'en', 'it', 'fr'], true)) {
|
||
$lang = 'en';
|
||
}
|
||
|
||
if (!isset($pageTitle) || !is_string($pageTitle) || $pageTitle === '') {
|
||
$pageTitle = app_primary_domain();
|
||
}
|
||
|
||
if (!isset($pageDescription) || !is_string($pageDescription)) {
|
||
$pageDescription = '';
|
||
}
|
||
|
||
// Standard-Script für Header-Interaktionen
|
||
if (function_exists('tpl_add_script')) {
|
||
tpl_add_script('/assets/js/header.js', 'footer', true, false, '', null);
|
||
}
|
||
|
||
// Scheme + Host + Request-URI für Canonical & sonstige Host-bezogene Dinge
|
||
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||
$host = $_SERVER['HTTP_HOST'] ?? app_primary_domain();
|
||
$requestUri = $_SERVER['REQUEST_URI'] ?? '/';
|
||
|
||
// Canonical bestimmen:
|
||
// - Wenn $canonical gesetzt ist (z. B. auf einer Landingpage explizit)
|
||
// → diese URL verwenden
|
||
// - Sonst: aktuelle URL ohne Query-Parameter (alles hinter '?')
|
||
$effectiveCanonical = isset($canonical) && is_string($canonical) && $canonical !== ''
|
||
? $canonical
|
||
: ($scheme . '://' . $host . strtok($requestUri, '?'));
|
||
|
||
// Kann später genutzt werden, falls du host-spezifische Sachen brauchst
|
||
?>
|
||
<!DOCTYPE html>
|
||
<html lang="<?= htmlspecialchars($lang) ?>">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<title><?= htmlspecialchars($pageTitle) ?></title>
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
|
||
<?php if ($pageDescription !== ''): ?>
|
||
<meta name="description" content="<?= htmlspecialchars($pageDescription) ?>">
|
||
<?php endif; ?>
|
||
|
||
<!-- Canonical URL -->
|
||
<link rel="canonical" href="<?= htmlspecialchars($effectiveCanonical) ?>">
|
||
|
||
<!-- Fonts -->
|
||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Montserrat:wght@600;700;800&display=swap" rel="stylesheet">
|
||
<?php tpl('app_config', 'structure'); ?>
|
||
|
||
<?php
|
||
|
||
// CSS im Header
|
||
foreach ($GLOBALS['page_styles'] as $style) {
|
||
if ($style['pos'] !== 'header') {
|
||
continue;
|
||
}
|
||
|
||
$href = $style['href'];
|
||
if (!empty($style['version'])) {
|
||
$href .= (str_contains($href, '?') ? '&' : '?') . 'v=' . urlencode($style['version']);
|
||
}
|
||
|
||
echo '<link rel="stylesheet" href="' . htmlspecialchars($href) . '">' . PHP_EOL;
|
||
}
|
||
|
||
// Scripts im Header
|
||
foreach ($GLOBALS['page_header_scripts'] as $script) {
|
||
$src = $script['src'];
|
||
if (!empty($script['version'])) {
|
||
$src .= (str_contains($src, '?') ? '&' : '?') . 'v=' . urlencode($script['version']);
|
||
}
|
||
|
||
$attr = '';
|
||
if ($script['async']) {
|
||
$attr .= ' async';
|
||
} elseif ($script['defer']) {
|
||
$attr .= ' defer';
|
||
}
|
||
if ($script['type']) {
|
||
$attr .= ' type="' . htmlspecialchars($script['type']) . '"';
|
||
}
|
||
|
||
echo '<script src="' . htmlspecialchars($src) . '"' . $attr . '></script>' . PHP_EOL;
|
||
}
|
||
?>
|
||
|
||
<script>
|
||
window.tailwind = window.tailwind || {};
|
||
window.tailwind.config = {
|
||
theme: {
|
||
extend: {
|
||
colors: {
|
||
'brand-primary': '#3a6ff8',
|
||
'brand-primarySoft': '#e8f1ff',
|
||
'brand-border': '#dfe6f4',
|
||
'brand-bg': '#f9fbff',
|
||
'brand-surface': '#ffffff',
|
||
'brand-text': '#0f1f3d',
|
||
'brand-muted': '#5f6b85'
|
||
},
|
||
fontFamily: {
|
||
heading: ['"Montserrat"', '"Plus Jakarta Sans"', '"Inter"', 'system-ui', 'sans-serif']
|
||
},
|
||
borderRadius: {
|
||
xl2: '1.75rem',
|
||
xl3: '2.25rem'
|
||
},
|
||
boxShadow: {
|
||
soft: '0 18px 45px rgba(58, 111, 248, 0.18)'
|
||
}
|
||
}
|
||
}
|
||
};
|
||
</script>
|
||
<!-- Tailwind (Dev) -->
|
||
<script src="https://cdn.tailwindcss.com"></script>
|
||
|
||
|
||
<!-- Eigenes CSS -->
|
||
<link rel="stylesheet" href="/assets/css/main.css">
|
||
</head>
|
||
|
||
<body class="bg-brand-bg text-brand-text font-sans antialiased scroll-smooth">
|
||
<div class="min-h-screen flex flex-col">
|
||
|
||
<!-- HEADER -->
|
||
<?php tpl('header'); ?>
|
||
|
||
<!-- MAIN CONTENT -->
|
||
<main class="flex-1">
|