feat(docs): add clickable anchor links to headings#2053
Open
maxffarrell wants to merge 2 commits into
Open
Conversation
Port of shadcn-ui/ui@bc2db187 — wraps h1–h6 MDX components with a HeadingAnchor component that renders a clickable `#` link on hover, leveraging the existing rehype-slug-generated IDs. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
Contributor
built with Refined Cloudflare Pages Action⚡ Cloudflare Pages Deployment
|
HTMLAttributes<HTMLHeadingElement> types id as string | null | undefined, but HeadingAnchor expects string | undefined — coerce null to undefined. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
Up to you if you want to merge! Useful but a little ugly |
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
Port of shadcn-ui/ui@bc2db187.
HeadingAnchorSvelte component that wraps heading content with a clickable#anchor linkh1–h6) to explicitly accept and pass through theidprop (already set byrehype-slug) and wrap children withHeadingAnchor#symbol and underline the text, linking to#<heading-id>for easy deep-linkingImplementation notes
The bits-ui docs already use
rehype-slug(inmdsx.config.js) which auto-generatesidattributes on headings from their text content. TheHeadingAnchorcomponent reuses those existing IDs rather than computing them from scratch (as shadcn does). The result is equivalent: every heading becomes a shareable anchor link.Test plan
#on hover and link to#<id>id(norehype-slugid) render children as plain text (no broken link)🤖 Generated with Claude Code