Skip to content

Conversation

@bluwy
Copy link
Contributor

@bluwy bluwy commented Oct 27, 2025

Description

Supports title in code blocks:

```js [filename.js]
// ...
```

The title bar design is based on the code group tabs design. Previously, support for this syntax is indirectly added by https://github.com/yuyinws/vitepress-plugin-group-icons, so I had to make sure the changes I make can still somewhat work with the plugin, however I need to patch it slightly to prevent double title bars added by us and them.

cc @yuyinws the plugin might need a new option to disable its own [title] support if this PR is merged. I couldn't figure out an automatic way for the plugin to detect this feature.

Linked Issues

fixes #3746

Additional Context

I've skipped support for title bar support for code snippets as there's no syntax to disable it at the moment. The snippets extensions always adds a title, causing it to be shown expectedly, e.g. the CLI output docs here may show init.ansi as the title.

Comment on lines +20 to +21
// @ts-ignore
const isFromSnippet = !!token.src
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src here is added by snippet.ts, however I think it's better if it's token.meta.src instead similar to how githubAlerts.ts uses it. But I didn't change it here as I don't want to accidentally break downstream if they use this internal info.

@yuyinws
Copy link
Contributor

yuyinws commented Oct 27, 2025

What if we migrate vitepress-plugin-group-icons to Vitepress as a built-in feature?

After this, all projects that used this plugin can safely remove it after upgrading to the latest version of Vitepress.

I'm happy to work for this.

cc @brc-dd

@bluwy
Copy link
Contributor Author

bluwy commented Oct 27, 2025

I think in a way this PR is already a partial migrate to make the title work, and is better to implement this single feature first, then we can decide to implement icon support on top.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 28, 2025

npm i https://pkg.pr.new/vitepress@5007

commit: dda3756

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

How to custom the title of code block like docusaurus?

3 participants