blog v4.15
Blocking absolute self-links
I kept accidentally writing absolute links back to my own site, which is fragile and breaks local preview. So I added a remark-no-self-links plugin that fails the build when content links to a production host (staffordwilliams.com) or to a local dev server route that belongs to the site, pointing me at the root-relative path or post:/link: shorthand I should have used instead. Drafts are exempt so works-in-progress aren’t blocked. One wrinkle: Astro’s glob loader swallows errors thrown during Markdown render, so during a build the plugin calls process.exit(1) to guarantee a non-zero status, while in dev it throws so the error overlay surfaces it. I also swept the existing content to fix the absolute links that were already lurking.
While I was in the link plumbing I fixed remark-post-links to tolerate a trailing slash on post: and link: references, so post:some-slug/ resolves the same as post:some-slug instead of failing to find the target.
More blog
The software that produces this blog · visit blog · devlog