Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

heading-links

Adds clickable anchor links to headings with auto-generated IDs and click-to-copy URL support.

Overview

Wraps a content area and adds a permalink anchor to each heading. Hover or focus a heading to reveal the link icon (on touch devices it is always shown); activating it jumps to the section, updates the URL hash, and copies the section URL to the clipboard.

Usage

Wrap any content containing headings. By default, h2 and h3 elements are processed.

Attributes

AttributeValuesDefaultDescription
levelsComma-separated h1–h6h2,h3Which heading levels to process. Other tokens are ignored (an all-invalid value falls back to the default). Changes are observed: headings that drop out of scope lose their anchor.
data-label-anchorTextCopy link toPrefix of each anchor's accessible name; the anchor is named prefix + heading text. Localise here.
data-label-copiedTextLink copied to clipboardScreen-reader announcement after a copy
data-toc-ignoreBoolean, on a heading or ancestor—Skip the heading(s): no anchor, no generated ID. Shared with <page-toc>.

Auto-generated IDs

Headings without an id attribute get one generated from their text content. Existing IDs are preserved. The slug is Unicode-aware: letters in any script keep their accents (Café crème → café-crème, 日本語の見出し stays as is), punctuation and emoji are dropped, whitespace becomes a hyphen, and the result is capped at 50 characters. A heading with no letters or numbers (emoji only) gets section. Duplicates get -1, -2… suffixes.

The site link checker (scripts/check-links.mjs) mirrors this rule, including the suffixes, so links to generated IDs are validated at build time.

Events

EventDetailDescription
heading-links:navigate{ id: string, url: string, heading: HTMLElement }Fired when an anchor is activated, after the fragment navigation and before the clipboard write

Behavior

  • Anchor icons appear on heading hover, on keyboard focus, and always on touch (no-hover) devices
  • Activating an anchor follows the fragment like a native link: :target updates, a history entry is added, the heading is focused, and the scroll is smooth (instant under prefers-reduced-motion). It stays on the page under <base href>.
  • Every activation writes to the clipboard: the absolute page URL plus the section hash
  • Ctrl/Cmd/Shift/Alt-clicks and middle clicks are left to the browser (open in new tab, etc.) and do not copy
  • A brief checkmark icon (data-state="copied" on the anchor) confirms the copy succeeded
  • Headings are skipped inside <dialog>, [data-toc-ignore], <browser-window> (demo content, not page sections) and a nested <heading-links> (which owns its own headings)
  • A MutationObserver watches for dynamically added headings

Accessibility

  • The heading keeps its own text as its accessible name: the text is wrapped in a .heading-text span the heading is labelled by, so the anchor does not add to it
  • Each anchor is named Copy link to [heading text] via aria-labelledby (prefix from data-label-anchor), so it follows text changes
  • Headings are made focusable with tabindex="-1" for keyboard navigation to anchored sections
  • Copy confirmation is announced through a role="status" live region outside the link
  • Focus-visible styles on anchor links

Styling

The anchor uses the .heading-anchor class. It is hidden by default (opacity: 0) and revealed on hover, focus, :target, and on no-hover devices. Headings get scroll-margin-block-start: calc(var(--site-header-height) + var(--size-m)) so a jump clears a sticky header.

Related

↑