Valkyrian Labs

Related Links

Render a Markdown list of links as uniform compact cards with :::related, with titles and descriptions the host can fill in.

Related Links

:::related turns an ordinary Markdown list of links into uniform compact cards: one card per list item, the item's link as the card's title and target, the rest of the item as its description. The source stays a plain list, so it reads as one on GitHub and in plain text.

1:::related2- [Remotes](/guide/remotes) How replicas find each other.3- [Sync settings](/reference/configuration#sync)4- [Conflict handling](/guide/conflicts) What happens when two replicas change the same file.5:::

Renders as:

Writing Items

  • Each item of a list directly inside the block is one card. The first link of the item's first paragraph is the title and the target; the item may start with it or wrap it in emphasis (**[Remotes](/guide/remotes)**).
  • Everything else in the item is the description: the rest of the first paragraph (a leading —, –, - or : after the link is dropped) and any further paragraphs or nested lists. Inline Markdown, code and other links work there.
  • Any other Markdown in the block (an intro paragraph, say) renders in place.
  • Reference-style links ([Remotes][remotes]) are text here; use inline links or autolinks (<https://example.com>).

The links stay ordinary Markdown links: they are in the render result's links, and link rewriting and link checks (pmdocs) treat them like any other link.

Attributes

The label is not a heading: it does not enter the table of contents or take a heading id, so a page can have several related blocks without disturbing its outline. Use a real heading above the block when the section should be in the TOC.

Titles and Descriptions From the Host

A host that knows its pages can complete the cards through resolve.page in the render config (see resolve):

1await renderMarkdown(markdown, {2  resolve: {3    page: async (href) => lookUpPage(href), // { title?, description? } or null4  },5})

page is called with the link's URL as authored, once per URL and render, only for cards that need it:

  • the title replaces a link text that is empty or the URL itself ([](/guide/remotes), <https://example.com/orbit>);
  • the description is shown when the item has none.

Without a resolver, or when it returns nothing, the card shows what was written. A resolver that throws is reported as related-resolve-failed (a warning, at the item's line) and the card stays as written.

Output

1<nav data-directive="related" data-theme="default" aria-label="Related" class="vl-md-related …">2  <p class="vl-md-related-title">Related</p>3  <ul class="not-prose vl-md-related-list" role="list">4    <li class="vl-md-related-item">5      <a href="/guide/remotes" class="vl-md-related-link">Remotes</a>6      <div class="vl-md-related-description"><p class="vl-md-related-summary">How replicas find each other.</p></div>7    </li>8  </ul>9</nav>

The whole card is the link's target; links in the description stay separately clickable. Without the stylesheet the block is a labelled list of links. Items without a link carry vl-md-related-item--plain.

Themes

Built-in related themes:

  • default: cards on the page surface
  • muted: cards on the muted surface
  • plain: no card surface, a compact list

The cards follow --pmd-border, --pmd-surface (--pmd-surface-muted for muted) and --pmd-accent.

Diagnostics

  • related-no-links (warning): no list inside the block has an item with a link; the content renders as is.
  • related-item-no-link (warning): a list item without a link; it renders as a plain item.
  • invalid-id (warning): an #id that had to be changed or has no letters or digits.

The editor linter reports the same codes on the same lines. The skills' checker reports related-no-links and invalid-id; related-item-no-link needs the renderer.