Skip to content

docs: add shareable anchor links to docs headings#1227

Merged
baktun14 merged 1 commit into
mainfrom
docs/shareable-heading-anchors
May 25, 2026
Merged

docs: add shareable anchor links to docs headings#1227
baktun14 merged 1 commit into
mainfrom
docs/shareable-heading-anchors

Conversation

@baktun14
Copy link
Copy Markdown
Contributor

@baktun14 baktun14 commented May 25, 2026

Summary

  • Hover any docs heading to reveal a # icon; clicking copies the deep-link URL to the clipboard and scrolls to the section (with a brief green-checkmark confirmation).
  • Fixes the bug where refreshing a docs page with a hash (e.g. …/api-reference/#get-v2deployment-settings-dseq) sometimes landed behind the sticky header — the script re-runs scrollIntoView on load and hashchange.
  • Coverage:
    • All MD/MDX docs pages via rehype-slug + rehype-autolink-headings (configured in astro.config.mjs).
    • Custom .astro pages (api-reference.astro, api-documentation/getting-started.astro) use the same markup applied inline.
    • Shared CSS + clipboard/scroll JS live in docs-layout.astro so every docs page inherits them.

Test plan

  • Visit /docs/api-documentation/console-api/api-reference/ — hover any heading (h1 overview, group headers, endpoint rows, See also), confirm the # icon fades in
  • Click an anchor — URL hash updates, page scrolls below the sticky header, icon briefly turns green, clipboard contains the full URL
  • Reload …/api-reference/#get-v2deployment-settings-dseq — page lands on the right section (not behind the header)
  • Visit /docs/api-documentation/getting-started/ — same hover + click behaviour on the 6 section headings
  • Visit an MD/MDX page (e.g. /docs/api-documentation/sdk/quick-start/, /docs/api-documentation/rest-api/providers-api/) — every ## / ### has a working anchor
  • Dark mode — icon visible, data-copied green still legible
  • Right-side TOC / ApiReferencePanel still tracks the active section as before

Hover any docs heading to reveal a `#` icon; clicking it copies the
deep-link URL to the clipboard and scrolls to the section. Also fixes
the bug where refreshing a docs page with a hash sometimes landed
behind the sticky header — re-runs scrollIntoView after `load`.

- rehype-slug + rehype-autolink-headings for all MD/MDX docs pages
- manual markup on the custom .astro pages (api-reference, getting-started)
- shared CSS + clipboard/scroll JS in docs-layout so coverage is global
@baktun14 baktun14 merged commit 9f40c23 into main May 25, 2026
1 check failed
baktun14 added a commit that referenced this pull request May 25, 2026
PR #1227 added rehype-slug + rehype-autolink-headings globally and put the
anchor CSS (including a `scroll-margin-top` on every heading with an id)
plus clipboard/scroll JS in the shared docs layout. As a result the `#`
icon and the scroll override leaked onto every docs page — developers,
providers, getting-started, learn, node-operators, AEPs — when the intent
was to only ship this on the API documentation section.

- Add `apiDocsOnly`, a small unified-plugin wrapper that only delegates
  to the inner plugin when the markdown vfile is under
  `src/content/Docs/api-documentation/`.
- Wrap both rehype plugins with it in `astro.config.mjs`.
- Gate the anchor `<style is:global>` and `<script>` in `docs-layout.astro`
  behind `Astro.url.pathname.startsWith("/docs/api-documentation/")`.

Manual anchor markup on the custom `.astro` pages
(`api-documentation/console-api/api-reference.astro`,
`api-documentation/getting-started.astro`) is unchanged — those pages
already live under the gated path so the layout's CSS + JS still apply.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant