forked from laysense/laysense.cn
84 lines
4.2 KiB
PHP
84 lines
4.2 KiB
PHP
<?php
|
|
use App\Content\View;
|
|
use App\Content\Assets;
|
|
use App\Content\SiteDesign;
|
|
|
|
$e = View::escape(...);
|
|
$canonical = $path !== null ? View::absolute($path) : null;
|
|
$imageUrl = !empty($socialImage) ? $socialImage : '/assets/original/home-hero.webp';
|
|
$imageUrl = Assets::url($imageUrl, $cdn);
|
|
if (str_starts_with($imageUrl, '/')) {
|
|
$imageUrl = View::absolute($imageUrl);
|
|
}
|
|
$kind = in_array($page['slug'] ?? '', ['sc', 'shnu-sc'], true) ? 'service' : 'software';
|
|
$siteKind = $kind === 'service' ? 'other' : 'software';
|
|
$header = ($site['header'] ?? []) + SiteDesign::DEFAULT_HEADER;
|
|
$footer = SiteDesign::footer($site);
|
|
$nav = $header['links'];
|
|
$contact = $header['button'];
|
|
$theme = $page['theme'] ?? '';
|
|
?>
|
|
<!doctype html>
|
|
<html lang="zh-CN" data-type="<?= $e($kind) ?>" data-buttons="solid" data-motion="on">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?= $e($title) ?></title>
|
|
<meta name="description" content="<?= $e($description) ?>">
|
|
<meta name="theme-color" content="#f5f7fb">
|
|
<meta name="page-type" content="<?= $e($kind) ?>">
|
|
<meta name="site-kind" content="<?= $e($siteKind) ?>">
|
|
<?php if ($canonical): ?>
|
|
<link rel="canonical" href="<?= $e($canonical) ?>">
|
|
<meta property="og:url" content="<?= $e($canonical) ?>">
|
|
<?php endif ?>
|
|
<?php if (!empty($noindex)): ?><meta name="robots" content="noindex"><?php endif ?>
|
|
<meta property="og:type" content="<?= isset($article) ? 'article' : 'website' ?>">
|
|
<meta property="og:locale" content="zh_CN">
|
|
<meta property="og:site_name" content="来笙 Laysense">
|
|
<meta property="og:title" content="<?= $e($title) ?>">
|
|
<meta property="og:description" content="<?= $e($description) ?>">
|
|
<meta property="og:image" content="<?= $e($imageUrl) ?>">
|
|
<meta property="og:image:alt" content="<?= $e(($socialAlt ?? '') ?: '来笙 Laysense') ?>">
|
|
<?php if (isset($article)): ?>
|
|
<meta property="article:published_time" content="<?= $e(View::date($article['published_at'], DATE_ATOM)) ?>">
|
|
<meta property="article:modified_time" content="<?= $e(View::date($article['updated_at'], DATE_ATOM)) ?>">
|
|
<?php endif ?>
|
|
<meta name="twitter:card" content="summary_large_image">
|
|
<link rel="icon" href="/assets/favicon.png" type="image/png">
|
|
<link rel="stylesheet" href="/assets/site.css">
|
|
<?php if ($theme !== ''): ?><link rel="stylesheet" href="/assets/page-themes.css"><?php endif ?>
|
|
<script src="/assets/jquery-4.0.0.min.js" defer></script>
|
|
<script src="/assets/site.js" defer></script>
|
|
</head>
|
|
<body<?= $kind === 'service' ? ' class="copyright-service"' : '' ?>>
|
|
<a class="skip-link" href="#main-content">跳到内容</a>
|
|
<header class="masthead">
|
|
<div class="wrap masthead-inner">
|
|
<a class="wordmark" href="/" aria-label="来笙 Laysense 首页">
|
|
<?php if ($header['logo'] !== ''): ?>
|
|
<img src="<?= $e($header['logo']) ?>" alt="<?= $e($header['alt']) ?>" width="130" height="33">
|
|
<?php else: ?>来笙 Laysense<?php endif ?>
|
|
</a>
|
|
<button class="menu-toggle" type="button" aria-expanded="false" aria-controls="primary-navigation" hidden>
|
|
<span></span><span></span><span class="sr-only">菜单</span>
|
|
</button>
|
|
<nav id="primary-navigation" class="primary-nav" aria-label="主导航">
|
|
<?php foreach ($nav as [$url, $label]): ?>
|
|
<?php $current = $url === $path || ($url === '/articles' && str_starts_with($path ?? '', '/articles')); ?>
|
|
<a href="<?= $e($url) ?>" <?= $current ? 'aria-current="page"' : '' ?>><?= $e($label) ?></a>
|
|
<?php endforeach ?>
|
|
<?php if ($contact): ?>
|
|
<a class="mobile-contact" href="<?= $e($contact[0]) ?>"><?= $e($contact[1]) ?></a>
|
|
<?php endif ?>
|
|
</nav>
|
|
<?php if ($contact): ?>
|
|
<a class="button button-outline masthead-action" href="<?= $e($contact[0]) ?>"><?= $e($contact[1]) ?></a>
|
|
<?php endif ?>
|
|
</div>
|
|
</header>
|
|
<main id="main-content"<?= $theme !== '' ? ' class="page-theme theme-' . $e($theme) . '"' : '' ?> tabindex="-1"><?= $content ?></main>
|
|
<?= View::fragment('footer', ['footer' => $footer]) ?>
|
|
</body>
|
|
</html>
|