Skip to content

feat: enhance code block #2178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
May 24, 2025
Merged

feat: enhance code block #2178

merged 10 commits into from
May 24, 2025

Conversation

yuyinws
Copy link
Contributor

@yuyinws yuyinws commented May 21, 2025

Previous discuss.

docs.

This PR implementing the code block and code group features in Slidev's slide like vitepress-plugin-group-icons.
It is implemented on top of UnoCSS's PresetIcon feature.

Usage

Code Group

input

## Code Group

::code-group

```sh [pnpm]
pnpm add slidev
```

```sh [yarn]
yarn add slidev
```

```sh [npm]
npm i slidev
```

```sh [bun]
bun add slidev
```

::

## Code Block with title

```ts [vite.config.ts]
import vue from '@vitejs/plugin-vue'
import { defineConfig } from 'vite'

export default defineConfig({
  plugins: [vue()],
})
```

Output

image

Custom Icon

It's also support specify the icon manually:

Input

```sh [Dockerfile ~i-vscode-icons:file-type-docker~]
FROM node:18-alpine

WORKDIR /app

COPY package.json .

RUN npm install
```

Output

image

Copy link

netlify bot commented May 21, 2025

Deploy Preview for slidev ready!

Name Link
🔨 Latest commit ae41ac6
🔍 Latest deploy log https://app.netlify.com/projects/slidev/deploys/683140b77fe53d0008e36726
😎 Deploy Preview https://deploy-preview-2178--slidev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Copy link

pkg-pr-new bot commented May 21, 2025

Open in StackBlitz

@slidev/client

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/client@2178

create-slidev

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev@2178

create-slidev-theme

npm i https://pkg.pr.new/slidevjs/slidev/create-slidev-theme@2178

@slidev/parser

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/parser@2178

@slidev/cli

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/cli@2178

@slidev/types

npm i https://pkg.pr.new/slidevjs/slidev/@slidev/types@2178

commit: ae41ac6

@yuyinws yuyinws changed the title feat: enhanced code block feat: enhance code block May 21, 2025
@yuyinws yuyinws marked this pull request as ready for review May 23, 2025 14:03
@antfu
Copy link
Member

antfu commented May 24, 2025

Wow, looks awesome! Thanks a lot for working on it with the high quality PR!

@antfu antfu merged commit 8f670f9 into slidevjs:main May 24, 2025
16 checks passed
@yuyinws yuyinws deleted the feat/code-block-icon branch May 24, 2025 08:46
@adamdehaven
Copy link
Contributor

adamdehaven commented May 25, 2025

It looks like the icons aren't automatically available -- does this require installing a separate package for the icons? It looks like I need to install vitepress-plugin-group-icons

@adamdehaven
Copy link
Contributor

Would be awesome to have this work alongside the magic-move as well

@yuyinws
Copy link
Contributor Author

yuyinws commented May 26, 2025

It looks like the icons aren't automatically available -- does this require installing a separate package for the icons? It looks like I need to install vitepress-plugin-group-icons

No need to install vitepress-plugin-group-icons. But you should install the icon's iconify collection first, like @iconify-json/vscode-icons. I'll mention it in the docs later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants