Skip to content

Related links

What sits under a post and points elsewhere, one look for all three kinds.

<nav class="cap-related" data-kind="internal" aria-labelledby="related-internal" id="sample-internal">
  <h2 class="cap-related-title" id="related-internal">Linked from</h2>
  <ul class="cap-related-list">
    <li><a class="cap-related-name" href="#getting-started">Getting started</a></li>
    <li><a class="cap-related-name" href="#spring-update">Spring update: what changed on every site</a></li>
  </ul>
</nav>

Installation

// package.json: "capsomer": "github:DrDustinEdwards/capsomer#v0.152.2"
import "capsomer/tokens.css";
import "capsomer/base.css";
import "capsomer/related-links.css";

Usage

<nav class="cap-related" data-kind="internal" aria-labelledby="linked-from">
  <h2 class="cap-related-title" id="linked-from">Linked from</h2>
  <ul class="cap-related-list">
    <li><a class="cap-related-name" href="/writing/getting-started">Getting started</a></li>
  </ul>
</nav>

<section class="cap-related" data-kind="mentions" aria-labelledby="mentions">
  <h2 class="cap-related-title" id="mentions">Mentions</h2>
  <ul class="cap-related-list">
    <li>
      <a class="cap-related-name" href="https://example.com/alex" rel="nofollow ugc noopener noreferrer">Alex Rivera</a>
      <p class="cap-related-excerpt">Linked this from our release notes.</p>
      <time class="cap-related-date" datetime="2026-09-05T04:05:09.000Z">September 5, 2026</time>
    </li>
  </ul>
</section>
import { RelatedLinks } from "capsomer/react/related-links";

<RelatedLinks kind="internal" title="Linked from" items={[{ href: "/writing/getting-started", title: "Getting started" }]} />
<RelatedLinks kind="mentions" title="Mentions" items={mentions.map((m) => ({ href: m.authorUrl ?? m.sourceUrl, title: m.authorName ?? m.sourceUrl, excerpt: m.excerpt, date: m.decidedAt }))} />

Examples

Further reading (external)

<section class="cap-related" data-kind="external" aria-labelledby="related-external" id="sample-external">
  <h2 class="cap-related-title" id="related-external">Further reading</h2>
  <ul class="cap-related-list">
    <li><a class="cap-related-name" href="https://example.org/annual-report" rel="noopener noreferrer">Example Co annual report</a></li>
    <li><a class="cap-related-name" href="https://example.net/field-notes" rel="noopener noreferrer">Field notes from the survey team</a></li>
    <li><a class="cap-related-name" href="#getting-started">Getting started, on this site</a></li>
  </ul>
</section>

Mentions

<section class="cap-related" data-kind="mentions" aria-labelledby="related-mentions" id="sample-mentions">
  <h2 class="cap-related-title" id="related-mentions">Mentions</h2>
  <ul class="cap-related-list">
    <li>
      <a class="cap-related-name" href="https://example.com/alex" rel="nofollow ugc noopener noreferrer">Alex Rivera</a>
      <p class="cap-related-excerpt">The part about publishing the measurements rather than the conclusions is the bit I keep coming back to.</p>
      <span class="cap-related-date"><time class="cap-time" datetime="2026-09-05" data-format="date">September 5, 2026</time></span>
    </li>
    <li>
      <span class="cap-related-name">https://example.net/notes/2026/release-notes-and-a-very-long-address-with-no-spaces</span>
      <p class="cap-related-excerpt">Linked this from our release notes.</p>
      <span class="cap-related-date"><time class="cap-time" datetime="2026-10-12" data-format="date">October 12, 2026</time></span>
    </li>
  </ul>
</section>

API reference

PropTypeRequiredDoes
titlestringYes"Further reading", "Linked from", "Mentions".
kindRelatedKindYesinternal: pages on this site, in a nav. external: pages the author chose, in a section. In both a site path is a router link and an address elsewhere has rel="noopener noreferrer". mentions: a stranger's links, rel="nofollow ugc noopener noreferrer", with excerpt and date.
itemsreadonly RelatedItem[]Yes

Parts and data attributes

ClassIs
.cap-relatedthe root
.cap-related-datea part
.cap-related-excerpta part
.cap-related-lista part
.cap-related-namea part
.cap-related-titlea part
AttributeValues
data-kindinternal

Accessibility

KeyDoes
TabMoves through the links in reading order. A row whose address failed is text and takes no focus.
  • Each block is a landmark named by its title: a nav for internal links, a section otherwise, aria-labelledby its h2.
  • The date is a time with its ISO datetime.
  • Screen readers: no manual run, by decision; the axe scan and a front-end review stand in.