Files
laysense.cn/app/view/layout.php
T

63 lines
3.1 KiB
PHP

<?php
use App\Content\View;
use App\Content\Assets;
use App\Content\DesignLibrary;
$e = View::escape(...);
$canonical = $path !== null && empty($previewMode) ? View::absolute($path) : null;
$imageUrl = !empty($socialImage) ? Assets::url($socialImage, $cdn) : '';
if (str_starts_with($imageUrl, '/')) {
$imageUrl = View::absolute($imageUrl);
}
$theme = $page['theme'] ?? '';
$palette = DesignLibrary::find((int) ($page['palette_id'] ?? 0), 'palette');
$showHeader = $page['visibility']['header'] ?? true;
$showFooter = $page['visibility']['footer'] ?? true;
?>
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= $e($title) ?></title>
<link rel="icon" href="<?= $e(Assets::DEFAULT_ICON) ?>" type="image/webp">
<meta name="description" content="<?= $e($description) ?>">
<meta name="theme-color" content="#f5f7fb">
<?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="<?= $e($site['name']) ?>">
<meta property="og:title" content="<?= $e($title) ?>">
<meta property="og:description" content="<?= $e($description) ?>">
<?php if ($imageUrl !== ''): ?>
<meta property="og:image" content="<?= $e($imageUrl) ?>">
<meta property="og:image:alt" content="<?= $e($socialAlt ?? '') ?>">
<?php endif ?>
<?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="stylesheet" href="/assets/site.css">
<?php if (!empty($canvas) || str_contains($content, 'studio-style-')): ?><link rel="stylesheet" href="/canvas-style.css"><?php endif ?>
<?php if ($theme !== ''): ?><link rel="stylesheet" href="/assets/page-themes.css"><?php endif ?>
<?php if ($palette): ?><link rel="stylesheet" data-page-palette href="/palette/<?= $e($palette['id']) ?>.css?v=<?= $e($palette['version']) ?>"><?php endif ?>
<script src="/assets/jquery-4.0.0.min.js" defer></script>
<script src="/assets/site.js" defer></script>
</head>
<body>
<a class="skip-link" href="#main-content">跳到内容</a>
<?php if ($showHeader || !empty($canvas)): ?>
<?= View::fragment('header', compact('header', 'site', 'showHeader', 'visitor', 'member', 'path')) ?>
<?php endif ?>
<main id="main-content"<?= $theme !== '' ? ' class="page-theme theme-' . $e($theme) . '"' : '' ?> tabindex="-1"><?= $content ?></main>
<?php if ($showFooter || !empty($canvas)): ?>
<?= View::fragment('footer', compact('footer', 'site', 'showFooter')) ?>
<?php endif ?>
</body>
</html>