forked from laysense/laysense.cn
The services directory built each card title from the backing article, so /services linked to /articles/service-1..4 instead of the product pages the card already carries (PAGEPAN, HighSpeaker, /sc, /shnu-sc). Only the primary button used card.url, which made the title and the button disagree. Use the card URL for both, keeping the article page as fallback for entries without a configured URL, and add a dependency-free regression test.
46 lines
2.4 KiB
PHP
46 lines
2.4 KiB
PHP
<?php
|
|
use App\Content\Html;
|
|
use App\Content\View;
|
|
|
|
$e = View::escape(...);
|
|
?>
|
|
<section class="section catalog-hero">
|
|
<div class="wrap">
|
|
<nav class="breadcrumbs" aria-label="面包屑"><a href="/">首页</a><span aria-hidden="true">/</span><span aria-current="page">产品与服务</span></nav>
|
|
<h1>产品与服务</h1>
|
|
<p>自托管建站、开源智能 DNS 与软件著作权代理服务。</p>
|
|
</div>
|
|
</section>
|
|
<section class="section catalog-listing" aria-label="产品与服务目录">
|
|
<div class="wrap">
|
|
<?php if (!$products): ?><p class="empty-state">暂无可查看的产品和服务。</p><?php endif ?>
|
|
<div class="catalog-grid">
|
|
<?php foreach ($products as $product): ?>
|
|
<?php
|
|
// 目录卡片指向卡片自己配置的网址,文章页只在未设置网址时兜底。
|
|
$card = $product['card'];
|
|
$target = ($card['url'] ?? '') ?: '/articles/' . $product['slug'];
|
|
?>
|
|
<article class="catalog-card">
|
|
<?php if (!empty($card['image'])): ?>
|
|
<div class="catalog-image"><img src="<?= $e($card['image']) ?>" alt="<?= $e($card['alt'] ?? '') ?>" loading="lazy"></div>
|
|
<?php endif ?>
|
|
<div class="catalog-content">
|
|
<?php if (!empty($card['category_label'])): ?><p class="overline"><?= $e($card['category_label']) ?></p><?php endif ?>
|
|
<h2><a href="<?= $e($target) ?>"><?= $e($product['title']) ?></a></h2>
|
|
<?php if ($product['summary']): ?>
|
|
<p><?= $e($product['summary']) ?></p>
|
|
<?php else: ?>
|
|
<div class="rich"><?= Html::articleBody($product) ?></div>
|
|
<?php endif ?>
|
|
<div class="actions">
|
|
<a class="button button-primary" href="<?= $e($target) ?>"><?= $e(($card['label'] ?? '') ?: '了解详情') ?></a>
|
|
<?php if (!empty($card['extra_url'])): ?><a href="<?= $e($card['extra_url']) ?>"><?= $e(($card['extra_label'] ?? '') ?: '相关链接') ?></a><?php endif ?>
|
|
</div>
|
|
</div>
|
|
</article>
|
|
<?php endforeach ?>
|
|
</div>
|
|
</div>
|
|
</section>
|