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

47 lines
2.7 KiB
PHP

<?php
use App\Content\View;
$e = View::escape(...);
?>
<article class="section article-page" itemscope itemtype="https://schema.org/Article" data-enter>
<?php $card = $article['card']; ?>
<div class="wrap reading-wrap">
<a class="back-link" href="/articles">全部动态</a>
<header class="section-heading">
<div class="article-meta">
<?php foreach ($article['categories'] as $key => $name): ?>
<a href="/articles/category/<?= $e($key) ?>" itemprop="articleSection"><?= $e($name) ?></a>
<?php endforeach ?>
<?php if ($article['published_at']): ?><time itemprop="datePublished" datetime="<?= $e(View::date($article['published_at'], DATE_ATOM)) ?>"><?= $e(View::date($article['published_at'])) ?></time><?php endif ?>
<meta itemprop="dateModified" content="<?= $e(View::date($article['updated_at'], DATE_ATOM)) ?>">
</div>
<h1 itemprop="headline"><?= $e($article['title']) ?></h1>
<?php if ($article['summary']): ?><p itemprop="description"><?= $e($article['summary']) ?></p><?php endif ?>
<span itemprop="author" itemscope itemtype="https://schema.org/Organization"><meta itemprop="name" content="<?= $e($site['name']) ?>"></span>
</header>
<?php if (!empty($card['image'])): ?>
<img class="article-cover" src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>">
<?php endif ?>
<div class="rich prose" itemprop="articleBody">
<?php if (trim($articleHtml) !== ''): ?>
<?= $articleHtml ?>
<?php elseif (!$article['summary'] && empty($card['image']) && empty($card['url'])): ?>
<p class="empty-state">此文章的原文暂不可用。</p>
<?php endif ?>
</div>
<?php if (!empty($card['url']) || !empty($card['extra_url'])): ?>
<div class="actions">
<?php if (!empty($card['url'])): ?><a class="button button-primary" href="<?= $e($card['url']) ?>"><?= $e(($card['label'] ?? '') ?: '访问网站') ?></a><?php endif ?>
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
</div>
<?php endif ?>
<?php if ($article['tags']): ?>
<nav class="filter-nav" aria-label="文章标签">
<?php foreach ($article['tags'] as $tag): ?>
<a href="/articles/tag/<?= $e(rawurlencode($tag)) ?>"><?= $e($tag) ?></a>
<?php endforeach ?>
</nav>
<?php endif ?>
</div>
</article>