garden/wiki-links-and-backlinks.md🌿 budding
stage
budding
planted
2026-11-10
tags
[astro, markdown]

budding— Taking shape. Cleaned up, still growing.

Wiki-links and backlinks in Astro

A small Markdown plugin for double-bracket links, and a build-time scan for what links back.

Two pieces make the garden’s links work, and neither needs a dependency beyond what Astro already ships.

src/lib/wiki-links-plugin.ts is a plugin for Sätteri, the Markdown processor Astro 7 uses by default. It visits every text node and replaces [[note-id]] in text nodes with a link to /garden/note-id/. [[blog/post-id]] and [[til/note-id]] point at the other sections, and [[note-id|some text]] sets the link text. Without it, the plugin reads the target’s title from its frontmatter.

Code blocks and inline code are separate node types, so [[examples]] inside backticks are left alone. (Remark plugins still work, but only after installing @astrojs/markdown-remark and switching the whole site back to the older unified pipeline.)

Every content entry keeps its raw Markdown in entry.body. At build time, getLinkGraph() in src/lib/garden.ts scans each post, TIL and note for wiki-links and ordinary Markdown links to internal pages, and records the line each link sits on. That line becomes the preview under “linked from”.

A link to an unwritten note, like graph-view, is dimmed and not clickable. The garden index lists these under ls --not-planted-yet, which doubles as a list of ideas.

The check runs when the page is rendered, not when the Markdown is parsed. Astro caches parsed Markdown by file content, so a parse-time check would keep showing a link as missing after its note was written.

Open questions

  • Link previews on hover would make following an idea faster.
  • A graph view looks nice, but I’m not sure it helps anyone read.

↑↓ select ↵ open esc close