· 2 min read · updated
Linkable headings, AVIF covers and a draft badge
Headings in markdown have ids now. rehype-slug gives every heading an id from its text (## The base path → #the-base-path, a repeated one gets -1), and…
What we did
- Headings in markdown have ids now.
rehype-sluggives every heading anidfrom its text (## The base path→#the-base-path, a repeated one gets-1), andrehype-autolink-headingswithbehavior: 'wrap'makes its text a link to itself. A#shows on hover and focus (CSS, with empty alt text so it isn't read out). Posts and Devlog entries both get them. - The svelte pages already had ids on their section headings (13, used by
aria-labelledbyand the section navs), so#linksto those already worked. - Covers can be AVIF:
cover.avifjoins.png,.jpgand.webp. - A draft/published badge in dev (
PostStatus.svelte) on post cards and post headers: a dashed, muted "draft" or a green "published", each with a Lucide icon. It's not in the build at all. - The publishing guide (
content/blog/published/README.md) explains heading ids and AVIF.
What I learned
- SvelteKit checks
#linkswhile prerendering: a link to an id that isn't on the page fails the build withprerender_missing_id. I tested it with a link to#nope. - 'wrap' vs 'append': wrapping the heading's text in the link keeps its accessible name as it was ("The base path"). Appending a separate "#" link inside the heading would add that link's text to the heading's name.
- mdsvex 0.12 uses an older
unified(v9) than the rehype plugins (v11). They work on the same trees, so it runs fine, but TypeScript disagrees; one cast invite.config.ts, with a comment. - SvelteKit 3 renamed
$app/environmentto$app/env(dev,browser,building). - When a value only matters in dev,
devfrom$app/envleaves it out of the build completely: the badge isn't hidden there, it isn't there. - An AVIF source should be exported at a high quality: the build encodes it again, and compressing twice loses detail twice.
- With the sticky header, a jump to a heading stops below it, thanks to the
scroll-padding-block-startonhtmlfrom Phase 4.5.