Skip to content

Commit 63c1ed0

Browse files
yuyinwsbrc-dd
andcommitted
docs: add vitepress-plugin-group-icons (#4437) [lunaria-ignore]
Co-authored-by: Divyansh Singh <[email protected]>
1 parent 74aa6fa commit 63c1ed0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+555
-689
lines changed

docs/.vitepress/config/shared.ts

+19
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ import { search as koSearch } from './ko'
55
import { search as ptSearch } from './pt'
66
import { search as ruSearch } from './ru'
77
import { search as zhSearch } from './zh'
8+
import {
9+
groupIconMdPlugin,
10+
groupIconVitePlugin,
11+
localIconLoader
12+
} from 'vitepress-plugin-group-icons'
813

914
export const shared = defineConfig({
1015
title: 'VitePress',
@@ -55,6 +60,7 @@ export const shared = defineConfig({
5560
`<button title="${codeCopyButtonTitle}" class="copy"></button>`
5661
)
5762
}
63+
md.use(groupIconMdPlugin)
5864
}
5965
},
6066

@@ -104,5 +110,18 @@ export const shared = defineConfig({
104110
},
105111

106112
carbonAds: { code: 'CEBDT27Y', placement: 'vuejsorg' }
113+
},
114+
vite: {
115+
plugins: [
116+
groupIconVitePlugin({
117+
customIcon: {
118+
vitepress: localIconLoader(
119+
import.meta.url,
120+
'../../public/vitepress-logo-mini.svg'
121+
),
122+
firebase: 'logos:firebase'
123+
}
124+
})
125+
]
107126
}
108127
})

docs/.vitepress/theme/index.ts

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Theme from 'vitepress/theme'
2+
import 'virtual:group-icons.css'
3+
4+
export default Theme

docs/en/guide/custom-theme.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ interface EnhanceAppContext {
4949

5050
The theme entry file should export the theme as its default export:
5151

52-
```js
53-
// .vitepress/theme/index.js
52+
```js [.vitepress/theme/index.js]
5453

5554
// You can directly import Vue files in the theme entry
5655
// VitePress is pre-configured with @vitejs/plugin-vue.
@@ -72,8 +71,7 @@ Inside your layout component, it works just like a normal Vite + Vue 3 applicati
7271

7372
The most basic layout component needs to contain a [`<Content />`](../reference/runtime-api#content) component:
7473

75-
```vue
76-
<!-- .vitepress/theme/Layout.vue -->
74+
```vue [.vitepress/theme/Layout.vue]
7775
<template>
7876
<h1>Custom Layout!</h1>
7977
@@ -172,17 +170,15 @@ If you wish to distribute the theme as an npm package, follow these steps:
172170

173171
To consume an external theme, import and re-export it from the custom theme entry:
174172

175-
```js
176-
// .vitepress/theme/index.js
173+
```js [.vitepress/theme/index.js]
177174
import Theme from 'awesome-vitepress-theme'
178175

179176
export default Theme
180177
```
181178

182179
If the theme needs to be extended:
183180

184-
```js
185-
// .vitepress/theme/index.js
181+
```js [.vitepress/theme/index.js]
186182
import Theme from 'awesome-vitepress-theme'
187183

188184
export default {
@@ -195,8 +191,7 @@ export default {
195191

196192
If the theme requires special VitePress config, you will need to also extend it in your own config:
197193

198-
```ts
199-
// .vitepress/config.ts
194+
```ts [.vitepress/config.ts]
200195
import baseConfig from 'awesome-vitepress-theme/config'
201196

202197
export default {
@@ -207,8 +202,7 @@ export default {
207202

208203
Finally, if the theme provides types for its theme config:
209204

210-
```ts
211-
// .vitepress/config.ts
205+
```ts [.vitepress/config.ts]
212206
import baseConfig from 'awesome-vitepress-theme/config'
213207
import { defineConfigWithTheme } from 'vitepress'
214208
import type { ThemeConfig } from 'awesome-vitepress-theme'

docs/en/guide/data-loading.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ Data loaders can be used to fetch remote data, or generate metadata based on loc
88

99
A data loader file must end with either `.data.js` or `.data.ts`. The file should provide a default export of an object with the `load()` method:
1010

11-
```js
12-
// example.data.js
11+
```js [example.data.js]
1312
export default {
1413
load() {
1514
return {
@@ -84,8 +83,7 @@ export default {
8483

8584
When building a content focused site, we often need to create an "archive" or "index" page: a page where we list all available entries in our content collection, for example blog posts or API pages. We **can** implement this directly with the data loader API, but since this is such a common use case, VitePress also provides a `createContentLoader` helper to simplify this:
8685

87-
```js
88-
// posts.data.js
86+
```js [posts.data.js]
8987
import { createContentLoader } from 'vitepress'
9088

9189
export default createContentLoader('posts/*.md', /* options */)
@@ -135,8 +133,7 @@ import { data as posts } from './posts.data.js'
135133

136134
The default data may not suit all needs - you can opt-in to transform the data using options:
137135

138-
```js
139-
// posts.data.js
136+
```js [posts.data.js]
140137
import { createContentLoader } from 'vitepress'
141138

142139
export default createContentLoader('posts/*.md', {
@@ -162,8 +159,7 @@ Check out how it is used in the [Vue.js blog](https://github.com/vuejs/blog/blob
162159

163160
The `createContentLoader` API can also be used inside [build hooks](../reference/site-config#build-hooks):
164161

165-
```js
166-
// .vitepress/config.js
162+
```js [.vitepress/config.js]
167163
export default {
168164
async buildEnd() {
169165
const posts = await createContentLoader('posts/*.md').load()

docs/en/guide/deploy.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The following guides are based on some shared assumptions:
1010
- You are using the default build output directory (`.vitepress/dist`).
1111
- VitePress is installed as a local dependency in your project, and you have set up the following scripts in your `package.json`:
1212

13-
```json
13+
```json [package.json]
1414
{
1515
"scripts": {
1616
"docs:build": "vitepress build docs",
@@ -121,7 +121,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
121121

122122
1. Create a file named `deploy.yml` inside `.github/workflows` directory of your project with some content like this:
123123

124-
```yaml
124+
```yaml [.github/workflows/deploy.yml]
125125
# Sample workflow for building and deploying a VitePress site to GitHub Pages
126126
#
127127
name: Deploy VitePress site to Pages
@@ -204,7 +204,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
204204

205205
2. Create a file named `.gitlab-ci.yml` in the root of your project with the content below. This will build and deploy your site whenever you make changes to your content:
206206

207-
```yaml
207+
```yaml [.gitlab-ci.yml]
208208
image: node:18
209209
pages:
210210
cache:
@@ -237,7 +237,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
237237

238238
`firebase.json`:
239239

240-
```json
240+
```json [firebase.json]
241241
{
242242
"hosting": {
243243
"public": "docs/.vitepress/dist",
@@ -248,7 +248,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
248248

249249
`.firebaserc`:
250250

251-
```json
251+
```json [.firebaserc]
252252
{
253253
"projects": {
254254
"default": "<YOUR_FIREBASE_ID>"
@@ -276,7 +276,7 @@ Don't enable options like _Auto Minify_ for HTML code. It will remove comments f
276276

277277
2. Create a file called `static.json` in the root of your project with the below content:
278278

279-
```json
279+
```json [static.json]
280280
{
281281
"root": "docs/.vitepress/dist"
282282
}

docs/en/guide/extending-default-theme.md

+9-19
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ Before proceeding, make sure to first read [Using a Custom Theme](./custom-theme
2222

2323
The default theme CSS is customizable by overriding root level CSS variables:
2424

25-
```js
26-
// .vitepress/theme/index.js
25+
```js [.vitepress/theme/index.js]
2726
import DefaultTheme from 'vitepress/theme'
2827
import './custom.css'
2928

@@ -46,8 +45,7 @@ VitePress uses [Inter](https://rsms.me/inter/) as the default font, and will inc
4645

4746
To avoid including Inter in the build output, import the theme from `vitepress/theme-without-fonts` instead:
4847

49-
```js
50-
// .vitepress/theme/index.js
48+
```js [.vitepress/theme/index.js]
5149
import DefaultTheme from 'vitepress/theme-without-fonts'
5250
import './my-fonts.css'
5351

@@ -68,8 +66,7 @@ If you are using optional components like the [Team Page](../reference/default-t
6866

6967
If your font is a local file referenced via `@font-face`, it will be processed as an asset and included under `.vitepress/dist/assets` with hashed filename. To preload this file, use the [transformHead](../reference/site-config#transformhead) build hook:
7068

71-
```js
72-
// .vitepress/config.js
69+
```js [.vitepress/config.js]
7370
export default {
7471
transformHead({ assets }) {
7572
// adjust the regex accordingly to match your font
@@ -94,8 +91,7 @@ export default {
9491

9592
## Registering Global Components
9693

97-
```js
98-
// .vitepress/theme/index.js
94+
```js [.vitepress/theme/index.js]
9995
import DefaultTheme from 'vitepress/theme'
10096

10197
/** @type {import('vitepress').Theme} */
@@ -109,8 +105,7 @@ export default {
109105
```
110106

111107
If you're using TypeScript:
112-
```ts
113-
// .vitepress/theme/index.ts
108+
```ts [.vitepress/theme/index.ts]
114109
import type { Theme } from 'vitepress'
115110
import DefaultTheme from 'vitepress/theme'
116111

@@ -129,8 +124,7 @@ Since we are using Vite, you can also leverage Vite's [glob import feature](http
129124

130125
The default theme's `<Layout/>` component has a few slots that can be used to inject content at certain locations of the page. Here's an example of injecting a component into the before outline:
131126

132-
```js
133-
// .vitepress/theme/index.js
127+
```js [.vitepress/theme/index.js]
134128
import DefaultTheme from 'vitepress/theme'
135129
import MyLayout from './MyLayout.vue'
136130

@@ -142,8 +136,7 @@ export default {
142136
}
143137
```
144138

145-
```vue
146-
<!--.vitepress/theme/MyLayout.vue-->
139+
```vue [.vitepress/theme/MyLayout.vue]
147140
<script setup>
148141
import DefaultTheme from 'vitepress/theme'
149142
@@ -161,8 +154,7 @@ const { Layout } = DefaultTheme
161154

162155
Or you could use render function as well.
163156

164-
```js
165-
// .vitepress/theme/index.js
157+
```js [.vitepress/theme/index.js]
166158
import { h } from 'vue'
167159
import DefaultTheme from 'vitepress/theme'
168160
import MyComponent from './MyComponent.vue'
@@ -224,9 +216,7 @@ Full list of slots available in the default theme layout:
224216

225217
You can extend the default theme to provide a custom transition when the color mode is toggled. An example:
226218

227-
```vue
228-
<!-- .vitepress/theme/Layout.vue -->
229-
219+
```vue [.vitepress/theme/Layout.vue]
230220
<script setup lang="ts">
231221
import { useData } from 'vitepress'
232222
import DefaultTheme from 'vitepress/theme'

docs/en/guide/getting-started.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,7 @@ By default, VitePress stores its dev server cache in `.vitepress/cache`, and the
120120

121121
The config file (`.vitepress/config.js`) allows you to customize various aspects of your VitePress site, with the most basic options being the title and description of the site:
122122

123-
```js
124-
// .vitepress/config.js
123+
```js [.vitepress/config.js]
125124
export default {
126125
// site-level options
127126
title: 'VitePress',
@@ -147,7 +146,7 @@ VitePress also provides the ability to generate clean URLs, rewrite paths, and d
147146

148147
The tool should have also injected the following npm scripts to your `package.json` if you allowed it to do so during the setup process:
149148

150-
```json
149+
```json [package.json]
151150
{
152151
...
153152
"scripts": {

docs/en/guide/i18n.md

+3-6
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ docs/
1313

1414
Then in `docs/.vitepress/config.ts`:
1515

16-
```ts
16+
```ts [docs/.vitepress/config.ts]
1717
import { defineConfig } from 'vitepress'
1818

1919
export default defineConfig({
@@ -77,8 +77,7 @@ However, VitePress won't redirect `/` to `/en/` by default. You'll need to confi
7777

7878
**Pro tip:** If using the above approach, you can use `nf_lang` cookie to persist user's language choice:
7979

80-
```ts
81-
// docs/.vitepress/theme/index.ts
80+
```ts [docs/.vitepress/theme/index.ts]
8281
import DefaultTheme from 'vitepress/theme'
8382
import Layout from './Layout.vue'
8483

@@ -88,9 +87,7 @@ export default {
8887
}
8988
```
9089

91-
```vue
92-
<!-- docs/.vitepress/theme/Layout.vue -->
93-
<script setup lang="ts">
90+
```vue [docs/.vitepress/theme/Layout.vue]<script setup lang="ts">
9491
import DefaultTheme from 'vitepress/theme'
9592
import { useData, inBrowser } from 'vitepress'
9693
import { watchEffect } from 'vue'

docs/en/guide/markdown.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -905,8 +905,7 @@ This is currently opt-in. To enable it, you need to install `markdown-it-mathjax
905905
npm add -D markdown-it-mathjax3
906906
```
907907

908-
```ts
909-
// .vitepress/config.ts
908+
```ts [.vitepress/config.ts]
910909
export default {
911910
markdown: {
912911
math: true

docs/en/guide/routing.md

+1-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,7 @@ packages/pkg-b/src/bar.md --> /pkg-b/bar.html
178178

179179
You can achieve this by configuring the [`rewrites`](../reference/site-config#rewrites) option like this:
180180

181-
```ts
182-
// .vitepress/config.js
181+
```ts [.vitepress/config.js]
183182
export default {
184183
rewrites: {
185184
'packages/pkg-a/src/index.md': 'pkg-a/index.md',

docs/en/guide/ssr-compat.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ if (!import.meta.env.SSR) {
5050
5151
Since [`Theme.enhanceApp`](./custom-theme#theme-interface) can be async, you can conditionally import and register Vue plugins that access browser APIs on import:
5252
53-
```js
54-
// .vitepress/theme/index.js
53+
```js [.vitepress/theme/index.js]
5554
/** @type {import('vitepress').Theme} */
5655
export default {
5756
// ...
@@ -65,8 +64,7 @@ export default {
6564
```
6665
6766
If you're using TypeScript:
68-
```ts
69-
// .vitepress/theme/index.ts
67+
```ts [.vitepress/theme/index.ts]
7068
import type { Theme } from 'vitepress'
7169

7270
export default {

docs/en/reference/default-theme-nav.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -165,8 +165,7 @@ Refer [`socialLinks`](./default-theme-config#sociallinks).
165165

166166
You can include custom components in the navigation bar by using the `component` option. The `component` key should be the Vue component name, and must be registered globally using [Theme.enhanceApp](../guide/custom-theme#theme-interface).
167167

168-
```js
169-
// .vitepress/config.js
168+
```js [.vitepress/config.js]
170169
export default {
171170
themeConfig: {
172171
nav: [
@@ -192,8 +191,7 @@ export default {
192191

193192
Then, you need to register the component globally:
194193

195-
```js
196-
// .vitepress/theme/index.js
194+
```js [.vitepress/theme/index.js]
197195
import DefaultTheme from 'vitepress/theme'
198196

199197
import MyCustomComponent from './components/MyCustomComponent.vue'

0 commit comments

Comments
 (0)