feat(tags): this adds support for post, link, book, show and movie tags with a tag list view and per tag pages

This commit is contained in:
Cory Dransfeldt 2025-04-16 18:59:47 -07:00
parent 3d866262ca
commit 6fdc0b56b9
No known key found for this signature in database
35 changed files with 500 additions and 70 deletions

View file

@ -23,7 +23,7 @@ schema: artist
height="200"
/>
<div class="media-meta">
<h2><?= htmlspecialchars($artist["name"]) ?></h2>
<h2 class="page-title"><?= htmlspecialchars($artist["name"]) ?></h2>
<span class="sub-meta country">{% tablericon "map-pin" %} <?= htmlspecialchars(
parseCountryField($artist["country"])
) ?></span>

View file

@ -24,7 +24,10 @@ schema: book
height="307"
/>
<div class="media-meta">
<h2><?= htmlspecialchars($book["title"]) ?></h2>
<h2 class="page-title"><?= htmlspecialchars($book["title"]) ?></h2>
<?php if (!empty($book["tags"])): ?>
<?php renderTags($book["tags"] ?? []); ?>
<?php endif; ?>
<?php if (!empty($book["rating"])): ?>
<span><?= htmlspecialchars($book["rating"]) ?></span>
<?php endif; ?>

View file

@ -4,7 +4,7 @@ type: dynamic
schema: genre
---
<a class="back-link" href="/music" title="Go back to the music index page">{% tablericon "arrow-left" %} Back to music</a>
<h2><?= htmlspecialchars($genre["emoji"]) ?> <?= htmlspecialchars($genre["name"]) ?></h2>
<h2 class="page-title"><?= htmlspecialchars($genre["emoji"]) ?> <?= htmlspecialchars($genre["name"]) ?></h2>
<article class="genre-focus">
<?php $artistCount = count($genre["artists"]); ?>
<?php if ($artistCount > 0): ?>

View file

@ -22,7 +22,10 @@ schema: movie
height="180"
/>
<div class="media-meta">
<h2><?= htmlspecialchars($movie["title"]) ?> (<?= htmlspecialchars($movie["year"]) ?>)</h2>
<h2 class="page-title"><?= htmlspecialchars($movie["title"]) ?> (<?= htmlspecialchars($movie["year"]) ?>)</h2>
<?php if (!empty($movie["tags"])): ?>
<?php renderTags($movie["tags"] ?? []); ?>
<?php endif; ?>
<?php if (!empty($movie["rating"])): ?>
<span><?= htmlspecialchars($movie["rating"]) ?></span>
<?php endif; ?>

View file

@ -22,7 +22,10 @@ schema: show
height="180"
/>
<div class="media-meta">
<h2><?= htmlspecialchars($show["title"]) ?> (<?= htmlspecialchars($show["year"]) ?>)</h2>
<h2 class="page-title"><?= htmlspecialchars($show["title"]) ?> (<?= htmlspecialchars($show["year"]) ?>)</h2>
<?php if (!empty($show["tags"])): ?>
<?php renderTags($show["tags"] ?? []); ?>
<?php endif; ?>
<?php if (!empty($show["favorite"])): ?>
<span class="sub-meta favorite">{% tablericon "heart" %} This is one of my favorite shows!</span>
<?php endif; ?>

View file

@ -0,0 +1,50 @@
---
permalink: /tags/index.php
type: dynamic
schema: tags
---
<a class="back-link" href="/tags" title="Go back to the tags index page">{% tablericon "arrow-left" %} Back to tags</a>
<h2 class="page-title">#<?= htmlspecialchars($tag) ?></h2>
<p><mark><?= number_format($totalCount) ?> item<?= $totalCount === 1 ? '' : 's' ?></mark>&thinsp;items tagged with <mark>#<?= htmlspecialchars($tag) ?></mark>. <a class="search" href="/search">You can search my site as well</a>.</p>
<hr />
<?php foreach ($tagged as $item): ?>
<article class="<?= $item['type'] ?>">
<aside>
<?php if (!empty($item['featured'])): ?>
<?= getTablerIcon('star') ?>
<?php endif; ?>
<time datetime="<?= date('F j, Y', strtotime($item['content_date'])) ?>">
<?= date('F j, Y', strtotime($item['content_date'])) ?>
</time>
• <?= $item['label'] ?>
</aside>
<h3>
<a href="<?= htmlspecialchars($item['url']) ?>"><?= htmlspecialchars($item['title']) ?><?php if (!empty($item['rating'])): ?>&thinsp;(<?= $item['rating'] ?>)<?php endif; ?></a>
<?php if (!empty($item['author'])): ?>
&thinsp;via&thinsp;
<?php if (!empty($item['author']['url'])): ?>
<a href="<?= $item['author']['url'] ?>">
<?= $item['author']['name'] ?>
</a>
<?php else: ?>
<?= $item['author']['name'] ?>
<?php endif; ?>
<?php endif; ?>
</h3>
<?php if (!empty($item["tags"])): ?>
<?php renderTags($item["tags"] ?? []); ?>
<?php endif; ?>
</a>
</article>
<?php endforeach; ?>
<?php renderPaginator($pagination, $totalPages); ?>
<?php
$html = ob_get_clean();
$htmlMin = new HtmlMin();
$htmlMin->doOptimizeAttributes(true);
$htmlMin->doRemoveComments(true);
$htmlMin->doSumUpWhitespace(true);
$htmlMin->doRemoveWhitespaceAroundTags(true);
$htmlMin->doOptimizeViaHtmlDomParser(true);
echo $htmlMin->minify($html);
?>