Skip to content

docs-site/satteri-relative-links

Sätteri mdast plugin that converts absolute internal links to relative links.

Function Description
satteriRelativeLinks Sätteri mdast plugin that converts absolute internal links to relative links. The generator emits markdown files with absolute links that embed the Astro config’s base path (e.g., /typescript-lib/api/...). When the base path is overridden at build time, those links break because they still reference the config-time base. This plugin strips the known base prefix, computes a relative path from the current file to the target, and rewrites the link. Relative links are also skipped by starlight-links-validator (errorOnRelativeLinks: false). Sätteri is Astro’s default Markdown processor as of Astro 7.3, and markdown.remarkPlugins now runs only on the separate unified processor from @astrojs/markdown-remark - which is no longer installed. This is the same rewrite expressed against Sätteri’s mdast visitor: a link visitor rather than a unist-util-visit walk, context.fileURL rather than file.history[0], and context.setProperty rather than assigning node.url, since the tree lives in Rust and mutations are recorded as commands rather than applied in place.