docs: add shareable anchor links to docs headings#1227
Merged
Conversation
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
4 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
#icon; clicking copies the deep-link URL to the clipboard and scrolls to the section (with a brief green-checkmark confirmation).…/api-reference/#get-v2deployment-settings-dseq) sometimes landed behind the sticky header — the script re-runsscrollIntoViewonloadandhashchange.rehype-slug+rehype-autolink-headings(configured inastro.config.mjs)..astropages (api-reference.astro,api-documentation/getting-started.astro) use the same markup applied inline.docs-layout.astroso every docs page inherits them.Test plan
/docs/api-documentation/console-api/api-reference/— hover any heading (h1 overview, group headers, endpoint rows, See also), confirm the#icon fades in…/api-reference/#get-v2deployment-settings-dseq— page lands on the right section (not behind the header)/docs/api-documentation/getting-started/— same hover + click behaviour on the 6 section headings/docs/api-documentation/sdk/quick-start/,/docs/api-documentation/rest-api/providers-api/) — every##/###has a working anchordata-copiedgreen still legibleApiReferencePanelstill tracks the active section as before