Skip to content

Commit 66649a1

Browse files
authored
docs: improve code groups section (#2185)
1 parent 21b1d96 commit 66649a1

File tree

1 file changed

+42
-15
lines changed

1 file changed

+42
-15
lines changed

docs/features/code-groups.md

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,17 @@ pnpm add @slidev/cli
3333

3434
## Title Icon Matching
3535

36-
`code groups` and `code block` also supports the automatically icon matching by the title name:
36+
`code groups` and `code block` also supports the automatically icon matching by the title name.
3737

3838
![code-groups-demo](/assets/code-groups-demo.png)
3939

40-
::: details All builtin icons
40+
::: info
41+
42+
By default, we provide some built-in icons, you can use them by install [@iconify-json/vscode-icons](https://www.npmjs.com/package/@iconify-json/vscode-icons).
43+
44+
:::
45+
46+
::: details All built-in icons
4147

4248
```js
4349
const builtinIcons = {
@@ -103,26 +109,47 @@ const builtinIcons = {
103109

104110
:::
105111

106-
## Custom Icon
112+
## Custom Icons
113+
114+
You can use any name from the [iconify](https://icones.js.org) collection by using the `~icon~` syntax, for example:
115+
116+
````md
117+
```js [npm ~i-uil:github~]
118+
console.log('Hello, GitHub!')
119+
```
120+
````
121+
122+
To make it work, you need to:
123+
124+
1. Install the icon's collection.
125+
126+
:::code-group
107127

108-
You can also specify the icon manually by the following steps:
128+
```sh [npm]
129+
npm add @iconify-json/uil
130+
```
109131

110-
1. Add the icon to the `uno.config.ts` file:
132+
```sh [yarn]
133+
yarn add @iconify-json/uil
134+
```
135+
136+
```sh [pnpm]
137+
pnpm add @iconify-json/uil
138+
```
139+
140+
```sh [bun]
141+
bun add @iconify-json/uil
142+
```
143+
144+
:::
145+
146+
2. Add the icon to the `uno.config.ts` file.
111147

112148
```ts [uno.config.ts] {3-5}
113149
import { defineConfig } from 'unocss'
114-
115150
export default defineConfig({
116151
safelist: [
117-
'i-vscode-icons:file-type-coverage',
152+
'i-uil:github',
118153
],
119154
})
120155
```
121-
122-
2. Use the icon in the code block with the `~icon~` syntax:
123-
124-
````md
125-
```sh [npm ~i-vscode-icons:file-type-coverage~]
126-
npm i @slidev/cli
127-
```
128-
````

0 commit comments

Comments
 (0)