· 2 min read · updated

Tag pages for the blog

Added /blog/tags/[tag]: one prerendered page per tag, with its posts grouped by year. /blog got a tag index with counts.

What we did

  • Added /blog/tags/[tag]: one prerendered page per tag, with its posts grouped by year. /blog got a tag index with counts.
  • content.ts exports postTags (every tag a post uses, once, A to Z) and postsTagged(tag).
  • checkTags fails the build when a tag isn't lowercase kebab-case, and the error names the file.
  • Moved the tag list out of TeaserCard and ArticleHeader into TagList.svelte. It only links tags when it gets a tagHref function. The blog passes blogTag (from links.ts), and the Devlog passes nothing.
  • handleUnseenRoutes ignores /blog/tags/[tag] too, while every post is a draft.

What I learned

  • Each entry's tags come from the .map() in toList. The list of all tags is one more step over the finished list (flatMap, then a Set, then sort). The .map() sees one file at a time, so it can't build that list.
  • postTags comes from allPosts, which has no drafts in a build. A tag only drafts use gets no page, with no extra code.
  • In a build with no published posts, entries() returns nothing and nobody links to the route, so the crawler reports it as unseen. Once a published post has a tag, its card links to that tag's page, so the page can't go unseen.
  • Passing a function (tagHref) keeps routes out of TagList. A Devlog tag like planning has no blog page: a hard-coded link would 404 and fail the build.
  • Rejecting a bad tag beats fixing it quietly. With CSS and css, a quiet fix would have to happen in postTags, postsTagged, the link and the label. With one rule, every place can trust the data, and the build tells me which file to fix.
  • Small links in a list (not in a sentence) need to be at least 24px tall (WCAG 2.5.8). padding-block makes them 26px.

Problems & fixes

  • Lighthouse gave the tag page 98 for heading-order: the h1 went straight to the cards' h3. Grouping by year, like /blog, adds h2s and brought it back to 100.
  • With every post a draft, a build has no tag pages to test. I copied one draft into content/blog/ for the checks, then deleted it.

Next

  • Open the Phase 7 PR.