refactor(site): centralize language storage key and clipboard helper#2779
refactor(site): centralize language storage key and clipboard helper#2779yonib05 wants to merge 14 commits into
Conversation
|
Assessment: Comment (approve once tests are addressed) Clean, well-scoped refactor. Extracting Review themes
Note: the diff surfaces the stacked #2778/#2775 commits, so I focused my review on the changes unique to this PR (the util module + key/clipboard wiring). Nice cleanup overall. |
Documentation Preview ReadyYour documentation preview has been successfully deployed! Preview URL: https://d3ehv1nix5p99z.cloudfront.net/pr-cms-2779/docs/user-guide/quickstart/overview/ Updated at: 2026-06-16T18:15:26.448Z |
|
Re-review of Nice follow-up — this is a clean consistency improvement. Verified:
No new issues from this commit. The two items from my earlier review remain open (they're unrelated to this refactor): the new |
06365a3 to
e6b93f6
Compare
|
Re-review of Clean follow-up that completes the dedup goal. Verified:
No new issues from this commit. The two items from my earlier reviews remain open and unrelated to this change: the |
e6b93f6 to
ad957c9
Compare
|
Re-review after rebase (HEAD The branch has been rebased, so the diff is now nicely isolated to this PR's scope. Re-verified the full change set via the file diffs:
Two items I can now close out:
Remaining (and only) substantive item: the Otherwise this is a clean, well-documented refactor — nice work. |
Extract the Starlight synced-tabs storage key and a copyToClipboard helper into a shared src/util/language-preference module. Processed scripts import it directly; the inline header and syntax-switch scripts receive the key via define:vars. Routes all copy buttons through the helper, fixing the pre-existing gap where a failed clipboard write still showed a copied state.
HeroSection's local withBase helper had a single remaining caller after the agent card moved to the shared util. Replace it with pathWithBase and remove the baseUrl prop and its threading through index.astro, matching how sibling landing sections resolve base paths.
ad957c9 to
4c22c3b
Compare
|
Re-review after rebase (HEAD This is a clean rebase onto updated My position is unchanged: the only outstanding item is the missing unit test for |
Description
Follow-up cleanup requested in review of #2775 and #2778: the
starlight-synced-tabs__jarkqtstorage key was a magic string duplicated acrossLanguageToggle.astro,Syntax.astro, andHeroSection.astro, andnavigator.clipboard.writeTextwas awaited without acatchin several copy buttons (including the pre-existingCodeBlock.astro), so the "copied" checkmark could flash even when the copy failed in a non-secure context.This PR introduces a small shared module
src/util/language-preference.tswith:LANGUAGE_STORAGE_KEY— single source of truth for the Starlight synced-tabs keycopyToClipboard(text)— wraps the clipboard write and returns whether it succeededand wires it in everywhere:
HeroSection,AgentSetupCard,CodeBlock) import the helpers directly.LanguageToggle,Syntax) receive the key viadefine:vars, sinceis:inlinescripts cannot import modules. Their tuned internals (idempotency guards, djb2-derived key contract) are otherwise untouched.Related Issues
Follow-up to review feedback on #2775 and #2778.
Documentation PR
No documentation changes needed.
Type of Change
Other (please describe): refactor / maintainability cleanup, no behavior change for end users
Testing
npm run typecheckandnpm run build(656 pages, no broken links) pass insite/Verified the built inline scripts receive the injected key (
define:varsemitsconst STORAGE_KEY = "starlight-synced-tabs__jarkqt"in bothLanguageToggleandSyntax); no hardcoded literal remains outside the shared moduleVerified language sync end-to-end in a headless browser:
define:vars)I ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.