Files
laysense.cn/app/view/page.php

84 lines
6.3 KiB
PHP

<?php
use App\Content\View;
$e = View::escape(...);
$home = $page['slug'] === 'home';
$service = in_array($page['slug'], ['sc', 'shnu-sc'], true);
$alignments = $page['alignments'];
$alignField = static fn (string $name): string => $canvas ? ' data-studio-align-field="' . $name . '"' : '';
$field = static fn (string $name): string => $canvas ? ' data-studio-field="' . $name . '"' : '';
?>
<section class="hero hero-<?= $e($page['slug']) ?>" id="home" data-enter>
<div class="wrap hero-inner<?= $page['image'] === '' ? ' hero-text-only' : '' ?>">
<div class="hero-copy">
<?php if (!$home): ?>
<nav class="breadcrumbs" aria-label="面包屑" itemscope itemtype="https://schema.org/BreadcrumbList">
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/"><span itemprop="name">首页</span></a>
<meta itemprop="position" content="1">
</span>
<span class="crumb-divider" aria-hidden="true">/</span>
<span itemprop="itemListElement" itemscope itemtype="https://schema.org/ListItem">
<a itemprop="item" href="/<?= $e($page['slug']) ?>" aria-current="page"><span itemprop="name"<?= $field('name') ?>><?= $e($page['name']) ?></span></a>
<meta itemprop="position" content="2">
</span>
</nav>
<?php else: ?>
<p class="overline hero-label"><?= $e($site['footer']['name'] ?? $site['name']) ?></p>
<?php endif ?>
<h1<?= isset($alignments['heading']) ? ' class="' . trim(View::alignmentClass($alignments['heading'])) . '"' : '' ?><?= $alignField('heading') ?>><span class="hero-heading-primary"<?= $field('heading') ?>><?= $e($page['heading']) ?></span><?php if ($canvas): ?><span class="studio-accent"<?= $field('accent') ?>><?= $e($page['accent']) ?></span><?php elseif ($page['accent'] !== ''): ?><br><span><?= $e($page['accent']) ?><?php if ($home): ?><span class="home-cursor" aria-hidden="true">_</span><?php endif ?></span><?php elseif ($home): ?><span class="home-cursor" aria-hidden="true">_</span><?php endif ?></h1>
<p class="hero-lead<?= View::alignmentClass($alignments['lead'] ?? null) ?>"<?= $field('lead') ?><?= $alignField('lead') ?>><?= $e($page['lead']) ?></p>
<div class="actions hero-actions<?= View::alignmentClass($alignments['actions'] ?? null) ?>"<?= $alignField('actions') ?>>
<?php foreach ($canvas ? array_pad($page['actions'], 2, ['', '']) : $page['actions'] as $index => [$url, $label]): ?>
<a class="button <?= $index ? 'button-outline' : 'button-primary' ?>" href="<?= $e($url) ?>"<?= $canvas ? ' data-studio-action="' . ($index + 1) . '"' : '' ?><?= $label === '' && $url === '' ? ' hidden' : '' ?>><?= $e($label) ?></a>
<?php endforeach ?>
</div>
</div>
<?php if ($canvas || $page['image'] !== ''): ?>
<div class="hero-visual <?= $home ? 'hero-illustration' : ($service ? 'hero-service-art' : 'app-frame') ?><?= $page['image_scale'] ? ' studio-media-' . $e($page['image_scale']) : '' ?><?= View::alignmentClass($alignments['image'] ?? null) ?>" data-visual<?= $alignField('image') ?><?= $page['image'] === '' ? ' hidden' : '' ?>>
<img<?= $page['image'] === '' ? '' : ' src="' . $e($page['image']) . '"' ?> alt="<?= $e($page['alt']) ?>" width="1448" height="1086" fetchpriority="high"<?= $canvas ? ' data-studio-hero-image' : '' ?>>
<?php if ($home && !$canvas && $page['image'] === '/assets/original/home-hero.webp'): ?>
<svg class="home-pipe-flow" viewBox="0 0 640 480" aria-hidden="true" focusable="false">
<defs>
<path id="hero-pipe-tower" pathLength="100" d="M174 347 241 312 Q246 310 246 305 L246 299 Q246 295 252 293 L273 282"/>
<path id="hero-pipe-disk" pathLength="100" d="M409 282 428 293 Q433 296 433 300 L433 304 Q433 307 438 309 L500 337"/>
<path id="hero-pipe-node" pathLength="100" d="M119 201 125 205 Q129 207 129 212 L129 214 Q130 217 134 219 L190 243"/>
<path id="hero-pipe-chart" pathLength="100" d="M443 226 471 213 Q478 208 483 209 L488 207 Q492 205 492 200 L492 182"/>
</defs>
<g class="home-pipe-route"><use href="#hero-pipe-tower"/><use href="#hero-pipe-tower"/></g>
<g class="home-pipe-route"><use href="#hero-pipe-disk"/><use href="#hero-pipe-disk"/></g>
<g class="home-pipe-route"><use href="#hero-pipe-node"/><use href="#hero-pipe-node"/></g>
<g class="home-pipe-route"><use href="#hero-pipe-chart"/><use href="#hero-pipe-chart"/></g>
</svg>
<?php endif ?>
</div>
<?php endif ?>
</div>
<?php foreach ($page['sections'] as $section): ?>
<?php if ($section['style'] === 'hero-links'): ?>
<?= View::fragment('section', ['section' => $section, 'moment' => false, 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
<?php endif ?>
<?php endforeach ?>
</section>
<?php if ($canvas || $page['quicklinks']): ?>
<nav class="section-nav" aria-label="本页目录"<?= $canvas ? ' data-studio-navigation' : '' ?><?= !$page['quicklinks'] ? ' hidden' : '' ?>>
<div class="wrap section-nav-inner">
<?php foreach ($page['quicklinks'] as [$url, $label]): ?>
<a href="<?= $e($url) ?>"><?= $e($label) ?></a>
<?php endforeach ?>
</div>
</nav>
<?php endif ?>
<?php foreach ($page['sections'] as $section): ?>
<?php if ($section['style'] !== 'hero-links'): ?>
<?= View::fragment('section', ['section' => $section, 'moment' => $home && $section['key'] === 'about', 'canvas' => $canvas, 'pageSlug' => $page['slug']]) ?>
<?php endif ?>
<?php endforeach ?>
<?php if ($canvas): ?>
<template data-studio-section-end><?= View::fragment('section', [
'section' => ['style' => 'plain', 'key' => 'new', 'version' => null, 'title' => '', 'lead' => '', 'body' => ''],
'moment' => false, 'canvas' => true,
]) ?></template>
<?php endif ?>