Edit shared headers and footers as page types
This commit is contained in:
+8
-11
@@ -4,25 +4,22 @@ use App\Content\View;
|
||||
$e = View::escape(...);
|
||||
$data = $footer['payload'];
|
||||
$brand = $data['brand'] ?: $site['name'];
|
||||
$layoutEditor ??= false;
|
||||
$part = static fn (string $component): string => $layoutEditor ? ' data-layout-component="' . $component . '"' : '';
|
||||
?>
|
||||
<footer class="site-footer site-footer-<?= $e($footer['preset']) ?>" id="contact"<?= $showFooter ? '' : ' hidden' ?>>
|
||||
<div class="wrap site-footer-components">
|
||||
<?php foreach ($data['components'] as $component): ?>
|
||||
<?php if ($component === 'brand'): ?>
|
||||
<a class="wordmark site-brand" href="/" aria-label="<?= $e($brand) ?>,首页"<?= $part('brand') ?>>
|
||||
<?php if ($layoutEditor): ?><img alt="" hidden><span data-layout-text="brand"></span>
|
||||
<?php elseif ($data['logo'] !== ''): ?><img src="<?= $e($data['logo']) ?>" alt="<?= $e($brand) ?>" loading="lazy"><?php else: ?><?= $e($brand) ?><?php endif ?>
|
||||
<a class="wordmark site-brand" href="/" aria-label="<?= $e($brand) ?>,首页">
|
||||
<?php if ($data['logo'] !== ''): ?><img src="<?= $e($data['logo']) ?>" alt="<?= $e($brand) ?>" loading="lazy"><?php else: ?><?= $e($brand) ?><?php endif ?>
|
||||
</a>
|
||||
<?php elseif ($component === 'text' && ($layoutEditor || $data['text'] !== '')): ?>
|
||||
<p class="site-footer-text"<?= $part('text') ?><?= $layoutEditor ? ' data-layout-text="text"' : '' ?>><?= $e($data['text']) ?></p>
|
||||
<?php elseif ($component === 'links' && ($layoutEditor || $data['links'])): ?>
|
||||
<nav class="site-footer-nav" aria-label="页脚导航"<?= $part('links') ?>>
|
||||
<?php elseif ($component === 'text' && $data['text'] !== ''): ?>
|
||||
<p class="site-footer-text"><?= $e($data['text']) ?></p>
|
||||
<?php elseif ($component === 'links' && $data['links']): ?>
|
||||
<nav class="site-footer-nav" aria-label="页脚导航">
|
||||
<?php foreach ($data['links'] as [$url, $label]): ?><a href="<?= $e($url) ?>"><?= $e($label) ?></a><?php endforeach ?>
|
||||
</nav>
|
||||
<?php elseif ($component === 'legal' && ($layoutEditor || $data['legal'] !== '')): ?>
|
||||
<small<?= $part('legal') ?><?= $layoutEditor ? ' data-layout-text="legal"' : '' ?>><?= $e($data['legal']) ?></small>
|
||||
<?php elseif ($component === 'legal' && $data['legal'] !== ''): ?>
|
||||
<small><?= $e($data['legal']) ?></small>
|
||||
<?php endif ?>
|
||||
<?php endforeach ?>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user