Skip to content

docs: clicking a heading's # link copies its URL - #1248

Merged
cdalar merged 1 commit into
mainfrom
docs-copy-heading-link
Oct 26, 2026
Merged

cdalar merged 1 commit into
mainfrom
docs-copy-heading-link

Conversation

@cdalar

@cdalar cdalar commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Follow-up to #1247. The hover # next to every heading on onctl.sh (homepage sections and docs pages alike) now copies the heading's full URL to the clipboard when clicked, and shows Link copied beside the # for 1.5 s. The default behaviour (hash goes in the address bar, page scrolls there) is unchanged.

Implementation: docs/src/theme/Heading/ is an ejected copy of theme-classic's Heading with the hash link swapped for one that also writes to navigator.clipboard. Details:

  • the theme's own .hash-link CSS is carried over, since only the original component loads it;
  • the link stays visible while in the copied state, because the click scrolls the heading out from under the cursor and the hover rule alone would hide the feedback;
  • the toast sits to the right of the #, not above it, since the heading lands just under the sticky navbar;
  • on touch screens (hover: none) the # is always visible.

Verified with headless Chrome against npm run build output: clipboard gets http://host/#tui on the homepage and http://host/docs/getting-started#initialize on a docs page, the toast appears and is gone after 1.6 s, light and dark mode both fine. npm run typecheck and npm run build pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J3DrQy8Pdg8KsM31aMxJaM

Eject the theme's Heading so the hover # link, besides putting the
hash in the address bar as before, writes the heading's full URL to
the clipboard and shows "Link copied" beside the # for 1.5s. The
link is kept visible on touch screens (no hover there) and while in
the copied state, since clicking scrolls the heading out from under
the cursor. The theme's own hash-link CSS comes along, as it is only
loaded by the original component.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J3DrQy8Pdg8KsM31aMxJaM
@codecov

codecov Bot commented Oct 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 47.57%. Comparing base (1d79ad2) to head (112810b).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1248   +/-   ##
=======================================
  Coverage   47.57%   47.57%           
=======================================
  Files          81       81           
  Lines        9341     9341           
=======================================
  Hits         4444     4444           
  Misses       4897     4897           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@cdalar
cdalar merged commit d54b936 into main Oct 26, 2026
13 checks passed
@cdalar
cdalar deleted the docs-copy-heading-link branch October 26, 2026 14:30
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

⌂ 换网址