feat: add copy-to-clipboard button to code blocks (resolves #361)#367
Merged
sumn2u merged 1 commit intosumn2u:mainfrom Feb 26, 2026
Merged
feat: add copy-to-clipboard button to code blocks (resolves #361)#367sumn2u merged 1 commit intosumn2u:mainfrom
sumn2u merged 1 commit intosumn2u:mainfrom
Conversation
|
@mhughes2012 is attempting to deploy a commit to the Suman Kunwar's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
sumn2u
approved these changes
Feb 26, 2026
Owner
sumn2u
left a comment
There was a problem hiding this comment.
LGTM! Thank you for adding this feature; readers will really benefit from it.
Owner
|
Resolves #367 |
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.
Overview
This PR implements a "Copy to Clipboard" functionality for all code blocks throughout the book. It uses a modern, language-agnostic icon approach to ensure the UI remains intuitive across all translated versions of the book without requiring additional i18n strings.
Key Changes
website/copy-code.jsandwebsite/copy-code.csscontaining the logic and styling for the copy buttons._layouts/layout.htmlto inject these assets usingbasePathto ensure correct relative pathing on both the homepage and nested language chapters._layoutsfolder has been included within each language directory (e.g.,/en/,/fr/)..bookignoreto ensure.jsassets are no longer excluded from the final output.Technical Implementation Details
#f7f7f7code block background.page.changeevents to ensure buttons are re-initialized when navigating between chapters without a full page reload.Testing Performed
localhost:4000).localhost:4000/en/,http://localhost:4000/es/,http://localhost:4000/fr/).