Skip to content

Commit dc06bbf

Browse files
yuyinwsszymonlicau
authored andcommitted
feat: enhance code block & code group (#3235)
* feat: enhance code block & code group * chore: fix line number * chore: duplicate code line
1 parent 05ecb28 commit dc06bbf

File tree

15 files changed

+351
-200
lines changed

15 files changed

+351
-200
lines changed

.vitepress/config.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type { Config as ThemeConfig } from '@vue/theme'
55
import baseConfig from '@vue/theme/config'
66
import { headerPlugin } from './headerMdPlugin'
77
// import { textAdPlugin } from './textAdMdPlugin'
8+
import { groupIconMdPlugin,groupIconVitePlugin } from 'vitepress-plugin-group-icons'
89

910
const nav: ThemeConfig['nav'] = [
1011
{
@@ -846,6 +847,7 @@ export default defineConfigWithTheme<ThemeConfig>({
846847
theme: 'github-dark',
847848
config(md) {
848849
md.use(headerPlugin)
850+
.use(groupIconMdPlugin)
849851
// .use(textAdPlugin)
850852
}
851853
},
@@ -874,6 +876,14 @@ export default defineConfigWithTheme<ThemeConfig>({
874876
},
875877
json: {
876878
stringify: true
877-
}
879+
},
880+
plugins: [
881+
groupIconVitePlugin({
882+
customIcon: {
883+
cypress: 'vscode-icons:file-type-cypress',
884+
'testing library': 'logos:testing-library'
885+
}
886+
}) as Plugin
887+
]
878888
}
879889
})

.vitepress/theme/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import ScrimbaLink from './components/ScrimbaLink.vue'
1414
// import Banner from './components/Banner.vue'
1515
// import TextAd from './components/TextAd.vue'
1616

17+
import 'vitepress/dist/client/theme-default/styles/components/vp-code-group.css'
18+
import 'virtual:group-icons.css'
19+
1720
export default Object.assign({}, VPTheme, {
1821
Layout: () => {
1922
// @ts-ignore

.vitepress/theme/styles/index.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@
44
@import "./inline-demo.css";
55
@import "./utilities.css";
66
@import "./style-guide.css";
7+
@import "./vars.css";

.vitepress/theme/styles/vars.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
:root {
2+
--vp-code-tab-active-bar-color: var(--vt-c-green);
3+
--vp-code-tab-active-text-color: var(--vt-c-text-inverse-1);
4+
--vp-code-tab-text-color: var(--vt-c-text-inverse-2);
5+
--vp-code-tab-hover-text-color: var(--vt-c-text-inverse-1);
6+
--vp-code-tab-bg: #292d3ef0;
7+
--vp-code-block-bg: #292d3ef0;
8+
}
9+
10+
.dark {
11+
--vp-code-tab-text-color: var(--vt-c-text-2);
12+
--vp-code-tab-hover-text-color: var(--vt-c-text-1);
13+
--vp-code-tab-active-text-color: var(--vt-c-text-1);
14+
--vp-code-tab-bg: var(--vt-c-black-mute);
15+
--vp-code-block-bg: var(--vt-c-black-mute);
16+
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@types/markdown-it": "^14.1.2",
2424
"@types/node": "^22.7.5",
2525
"typescript": "^5.6.3",
26+
"vitepress-plugin-group-icons": "^1.5.4",
2627
"vue-tsc": "^2.1.6"
2728
},
2829
"packageManager": "[email protected]"

0 commit comments

Comments
 (0)