Skip to content

Instantly share code, notes, and snippets.

@pftnhr
Last active October 26, 2023 07:05
Show Gist options
  • Save pftnhr/ed6e8db5efa03961f91545b044a6a3a6 to your computer and use it in GitHub Desktop.
Save pftnhr/ed6e8db5efa03961f91545b044a6a3a6 to your computer and use it in GitHub Desktop.
[datenstrom-yellow] PaperMod like tags page

yellow-tags

... creates a page that shows tags with a superscript count using the group() function of yellow. The inspiration for this comes from the tags page of the PaperMod theme for Hugo.

How it works

Save the tags.html in your system/layout folder and create a content/5-tags/page.md with the following page settings:

---
Title: Tags
Layout: tags
---
<?php $this->yellow->layout("header") ?>
<h1><?php echo $this->yellow->page->getHtml("titleContent") ?></h1>
<?php echo $this->yellow->page->getContentHtml() ?>
<?php $pages = $this->yellow->content->index()->filter("layout", "blog")->sort("published", false) ?>
<nav class="tags_nav">
<ul>
<?php foreach ($pages->group("tag") as $tag=>$collection): ?>
<li>
<a role="button" class="post_tag" title="Tag: <?php echo strtolower(htmlspecialchars($tag)) ?>" aria-label="Tag: <?php echo strtolower(htmlspecialchars($tag)) ?>" href="<?php echo $this->yellow->page->getBase() . "/" . $this->yellow->toolbox->normaliseArguments("tag:$tag") ?>">
<?php echo htmlspecialchars($tag) . " <sup><strong><sup>" . count($collection) . "</sup></strong></sup>" ?>
</a>
</li>
<?php endforeach ?>
</ul>
</nav>
<?php $this->yellow->layout("footer") ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment