From ac247d8ae8dff169ba8d451be1040f6cf6cac972 Mon Sep 17 00:00:00 2001 From: sea <45450994+warmthsea@users.noreply.github.com> Date: Tue, 14 Jan 2025 20:40:30 +0800 Subject: [PATCH] docs: add code file-title and icon (#19638) * docs: add code file-title and icon * chore: update deps --- docs/.vitepress/config/plugins.ts | 2 ++ docs/.vitepress/config/vite.ts | 2 ++ docs/.vitepress/theme/index.ts | 1 + docs/en-US/guide/dark-mode.md | 12 ++++------- docs/en-US/guide/dev-guide.md | 4 +--- docs/en-US/guide/i18n.md | 4 ++-- docs/en-US/guide/namespace.md | 8 +++----- docs/en-US/guide/quickstart.md | 34 ++++++++++++------------------- docs/en-US/guide/ssr.md | 16 +++++++-------- docs/en-US/guide/theming.md | 11 ++++------ docs/en-US/guide/transitions.md | 2 +- docs/package.json | 3 ++- pnpm-lock.yaml | 28 +++++++++++++++++++++++++ 13 files changed, 71 insertions(+), 56 deletions(-) diff --git a/docs/.vitepress/config/plugins.ts b/docs/.vitepress/config/plugins.ts index 60ecf4a175..63924fb0a5 100644 --- a/docs/.vitepress/config/plugins.ts +++ b/docs/.vitepress/config/plugins.ts @@ -1,4 +1,5 @@ import mdContainer from 'markdown-it-container' +import { groupIconMdPlugin } from 'vitepress-plugin-group-icons' import externalLinkIcon from '../plugins/external-link-icon' import tableWrapper from '../plugins/table-wrapper' import tooltip from '../plugins/tooltip' @@ -16,4 +17,5 @@ export const mdPlugin = (md: MarkdownRenderer) => { md.use(tag) md.use(mdContainer, 'demo', createDemoContainer(md)) md.use(ApiTableContainer) + md.use(groupIconMdPlugin as unknown as (md: MarkdownRenderer) => void) } diff --git a/docs/.vitepress/config/vite.ts b/docs/.vitepress/config/vite.ts index e9f170bd65..ed4722ccb7 100644 --- a/docs/.vitepress/config/vite.ts +++ b/docs/.vitepress/config/vite.ts @@ -8,6 +8,7 @@ import Components from 'unplugin-vue-components/vite' import Icons from 'unplugin-icons/vite' import IconsResolver from 'unplugin-icons/resolver' import { loadEnv } from 'vitepress' +import { groupIconVitePlugin } from 'vitepress-plugin-group-icons' import { docPackage, epPackage, @@ -100,6 +101,7 @@ export const getViteConfig = ({ mode }: { mode: string }): ViteConfig => { UnoCSS(), MarkdownTransform(), Inspect(), + groupIconVitePlugin(), env.HTTPS ? (mkcert() as Plugin) : undefined, ], optimizeDeps: { diff --git a/docs/.vitepress/theme/index.ts b/docs/.vitepress/theme/index.ts index dc68c02357..5de23987e0 100644 --- a/docs/.vitepress/theme/index.ts +++ b/docs/.vitepress/theme/index.ts @@ -8,6 +8,7 @@ import { define } from '../utils/types' import 'uno.css' import './style.css' import 'vitepress/dist/client/theme-default/styles/components/vp-code-group.css' +import 'virtual:group-icons.css' import type { Theme } from 'vitepress' export default define({ diff --git a/docs/en-US/guide/dark-mode.md b/docs/en-US/guide/dark-mode.md index 667abbb510..bcc71a0bc2 100644 --- a/docs/en-US/guide/dark-mode.md +++ b/docs/en-US/guide/dark-mode.md @@ -26,8 +26,7 @@ First you can create a switch to toggle `dark` class of html. Then, you can quickly enable it with just one line of code to import CSS in your entry. -```ts -// main.ts +```ts [main.ts] // if you just want to import css import 'element-plus/theme-chalk/dark/css-vars.css' ``` @@ -51,8 +50,7 @@ html.dark { Import it after styles of Element Plus: -```ts -// main.ts +```ts [main.ts] import 'element-plus/theme-chalk/dark/css-vars.css' import './styles/dark/css-vars.css' ``` @@ -63,8 +61,7 @@ If you use scss, you can also import scss file to compile. > You can refer [Theming](./theming.md) to get more info. -```scss -// styles/element/index.scss +```scss [styles/element/index.scss] /*just override what you need*/ @forward 'element-plus/theme-chalk/src/dark/var.scss' with ( $bg-color: ( @@ -75,8 +72,7 @@ If you use scss, you can also import scss file to compile. ); ``` -```ts -// main.ts +```ts [main.ts] import './styles/element/index.scss' // or just want to import scss? diff --git a/docs/en-US/guide/dev-guide.md b/docs/en-US/guide/dev-guide.md index 6c59be62e5..1b425ef63c 100644 --- a/docs/en-US/guide/dev-guide.md +++ b/docs/en-US/guide/dev-guide.md @@ -39,9 +39,7 @@ will start the local development environment. 2. Add your component into `play/src/App.vue` -> App.vue - -```vue +```vue [App.vue] diff --git a/docs/en-US/guide/i18n.md b/docs/en-US/guide/i18n.md index cce102a957..00e8ff50d6 100644 --- a/docs/en-US/guide/i18n.md +++ b/docs/en-US/guide/i18n.md @@ -12,7 +12,7 @@ languages, you can get you answer by keep reading. Element Plus provides global configurations -```ts +```ts [main.ts] import ElementPlus from 'element-plus' import zhCn from 'element-plus/es/locale/lang/zh-cn' @@ -26,7 +26,7 @@ app.use(ElementPlus, { Element Plus also provides a Vue component [ConfigProvider](/en-US/component/config-provider) for globally configuring locale and other settings. -```vue +```vue [App.vue]