-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
feat: Group name for Code Groups to sync opened tab #5012
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
juji
wants to merge
13
commits into
vuejs:main
Choose a base branch
from
juji:group-name
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
- Add optional group-name parameter to code-group containers - Validates group names (alphanumeric, hyphens, underscores only) - Adds data-group-name attribute to generated HTML - Includes E2E tests for validation and functionality - Updates documentation with usage examples and guidelines
- Add syncTabsInOtherGroups function to sync tabs across groups - When clicking a tab in a named group, all groups with same name sync - Add E2E test for synchronization behavior - Update documentation to explain sync purpose and usage - Add second test fixture for testing sync between groups
- Add second code group to output section - Users can now actually test the synchronization behavior - Add tip to encourage trying the interactive demo
4 tasks
|
doc changes: https://deploy-preview-5012--vitepress-docs.netlify.app/guide/markdown#named-code-groups need help for other langs |
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.
Description
This PR adds support for named code groups with automatic tab synchronization and localStorage persistence. When multiple code groups share the same
nameparameter, selecting a tab in one group automatically selects the corresponding tab in all other groups with the same name, and the preference is saved across page visits.What this PR adds:
nameparameter for code-group containersdata-group-name) added to HTML outputUse case:
This is especially useful in documentation where the same tool (e.g., package managers like npm/pnpm/yarn) is shown in multiple contexts throughout a page, providing a consistent and improved user experience. Users only need to select their preference once, and it persists across the entire documentation site.
Additional Context
Implementation highlights:
::: code-group name=package-managersvitepress:tabsCacheFiles changed:
src/node/markdown/plugins/containers.ts- Parsing and HTML generationsrc/client/app/composables/codeGroups.ts- Client-side synchronization logic and localStorage persistence__tests__/e2e/markdown-extensions/- E2E tests and fixturesdocs/*/guide/markdown.md- User documentation in all languagesTesting:
Translation needed:
docs/en/guide/markdown.md<!-- TODO: Translate to [Language] -->markersCode Example
Screen.Recording.2025-11-02.at.23.57.47.mov
Showing how it works. Also shows that on refresh, the last selected tab is still ON
Tip
The author of this PR can publish a preview release by commenting
/publishbelow.