Skip to content

Commit 74276dc

Browse files
authored
docs: sync (#235)
1 parent 257faaf commit 74276dc

File tree

19 files changed

+173
-99
lines changed

19 files changed

+173
-99
lines changed

.vitepress/addons.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,20 @@ export const official: AddonInfo[] = [
1515
]
1616

1717
export const community: AddonInfo[] = [
18+
{
19+
id: 'slidev-addon-tldraw',
20+
name: 'tldraw for Slidev',
21+
description: 'Embed tldraw diagrams directly in Slidev, with in-slide editing support',
22+
author: {
23+
name: 'Albert Brand',
24+
link: 'https://github.com/AlbertBrand',
25+
},
26+
repo: 'https://github.com/AlbertBrand/slidev-addon-tldraw',
27+
},
1828
// Add yours here!
1929
{
2030
id: '',
21-
link: 'https://github.com/slidevjs/docs/edit/main/.vitepress/addons.ts',
31+
link: 'https://github.com/slidevjs/slidev/edit/main/docs/.vitepress/addons.ts',
2232
name: 'Yours?',
2333
description: '点击此处分享你的插件',
2434
author: {

.vitepress/scripts/prepare.js

Lines changed: 0 additions & 8 deletions
This file was deleted.

.vitepress/showcases.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,18 @@ export const showcases: ShowCaseInfo[] = [
202202
cover: 'https://github-production-user-asset-6210df.s3.amazonaws.com/7693264/284304324-db973b4c-a043-4644-932c-826169a1b4d8.gif',
203203
datetime: '2022-09-01',
204204
},
205+
{
206+
title: 'Comparison of Packaging Tools in 2023',
207+
author: {
208+
name: 'Peacock (Yoichi Takai)',
209+
link: 'https://p3ac0ck.net',
210+
},
211+
at: 'PyCon APAC 2023',
212+
slidesLink: 'https://slides.p3ac0ck.net/pyconapac2023/1',
213+
sourceLink: 'https://github.com/peacock0803sz/slidev-slides/blob/7d41aa5e89ad8627cb68ae2cdbfe1681017b0408/talks/pyconapac2023/pyconapac2023.md',
214+
cover: 'https://slides.p3ac0ck.net/pyconapac2023/cover.png',
215+
datetime: '2023-10-28',
216+
},
205217
{
206218
title: 'How Rust error handling ease web development',
207219
author: {

.vitepress/theme/components/Demo.vue

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
<script setup lang="ts">
22
import { onMounted, ref, watch } from 'vue'
3-
43
import TypeIt from 'typeit'
54
import Markdown from 'markdown-it'
65
import type { SlidevMarkdown } from '@slidev/types'
7-
8-
import { parse } from '@slidev/parser'
6+
import { parseSync } from '@slidev/parser'
97
import Cover from '@slidev/theme-default/layouts/cover.vue'
108
import Default from '@slidev/client/layouts/default.vue'
119
import Center from '@slidev/client/layouts/center.vue'
12-
import SlideContainer from '@slidev/client/internals/SlideContainer.vue'
10+
import SlideContainer from './SlideContainer.vue'
1311
import '@slidev/client/styles/layouts-base.css'
1412
import '@slidev/theme-default/styles/layouts.css'
1513
@@ -38,7 +36,7 @@ watch([code, paused], () => {
3836
if (paused.value)
3937
return
4038
try {
41-
info.value = parse(code.value)
39+
info.value = parseSync(code.value, '')
4240
}
4341
catch {
4442
}

.vitepress/theme/components/LinkCard.vue

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,23 @@ const resolved = computed(() => resolveLink(props.link))
1111
</script>
1212

1313
<template>
14-
<a class="link-card" :href="withBase(resolved.url)">
15-
<div class="title">
16-
<div>{{ resolved.title }}</div>
17-
<div flex-grow />
18-
<div flex gap-1>
19-
<FeatureTag v-for="tag in resolved.tags" :key="tag" :tag />
14+
<div class="sr-only">
15+
{{ resolved.title }}
16+
</div>
17+
<ClientOnly>
18+
<a class="link-card" :href="withBase(resolved.url)">
19+
<div class="title">
20+
<div>{{ resolved.title }}</div>
21+
<div flex-grow />
22+
<div flex gap-1>
23+
<FeatureTag v-for="tag in resolved.tags" :key="tag" :tag />
24+
</div>
2025
</div>
21-
</div>
22-
<div class="description">
23-
{{ resolved.descripton }}
24-
</div>
25-
</a>
26+
<div class="description">
27+
{{ resolved.descripton }}
28+
</div>
29+
</a>
30+
</ClientOnly>
2631
</template>
2732

2833
<style scoped>

.vitepress/theme/components/LinkInline.vue

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,32 +12,35 @@ const resolved = computed(() => resolveLink(props.link))
1212
</script>
1313

1414
<template>
15-
<Tooltip class="inline-block" theme="twoslash">
16-
<a
17-
:href="withBase(resolved.url)"
18-
target="_blank"
19-
class="bg-$vp-c-default-soft hover:bg-$vp-c-brand-soft rounded px2 py1 !decoration-none"
20-
>
21-
{{ resolved.title }}
22-
</a>
23-
24-
<template #popper>
15+
<span class="sr-only">{{ resolved.title }}</span>
16+
<ClientOnly>
17+
<Tooltip class="inline-block" theme="twoslash">
2518
<a
2619
:href="withBase(resolved.url)"
2720
target="_blank"
28-
flex flex-col p4 gap-2 max-w-100
21+
class="bg-$vp-c-default-soft hover:bg-$vp-c-brand-soft rounded px2 py1 !decoration-none"
2922
>
30-
<div flex gap-2>
31-
<div>
32-
{{ resolved.title }}
33-
</div>
34-
<div flex-grow />
35-
<FeatureTag v-for="tag in resolved.tags" :key="tag" :tag :noclick="resolved.kind !== 'features'" text-xs />
36-
</div>
37-
<div op75 text-sm>
38-
{{ resolved.descripton }}
39-
</div>
23+
{{ resolved.title }}
4024
</a>
41-
</template>
42-
</Tooltip>
25+
26+
<template #popper>
27+
<a
28+
:href="withBase(resolved.url)"
29+
target="_blank"
30+
flex flex-col p4 gap-2 max-w-100
31+
>
32+
<div flex gap-2>
33+
<div>
34+
{{ resolved.title }}
35+
</div>
36+
<div flex-grow />
37+
<FeatureTag v-for="tag in resolved.tags" :key="tag" :tag :noclick="resolved.kind !== 'features'" text-xs />
38+
</div>
39+
<div op75 text-sm>
40+
{{ resolved.descripton }}
41+
</div>
42+
</a>
43+
</template>
44+
</Tooltip>
45+
</ClientOnly>
4346
</template>
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<script setup lang="ts">
2+
import { useElementSize } from '@vueuse/core'
3+
import { computed, ref } from 'vue'
4+
5+
const slideAspect = 16 / 9
6+
const slideWidth = 980
7+
const slideHeight = 980 * 9 / 16
8+
9+
const root = ref<HTMLDivElement>()
10+
const element = useElementSize(root)
11+
12+
const width = computed(() => element.width.value)
13+
const height = computed(() => element.height.value)
14+
15+
const screenAspect = computed(() => width.value / height.value)
16+
17+
const scale = computed(() => {
18+
if (screenAspect.value < slideAspect)
19+
return width.value / slideWidth
20+
return height.value * slideAspect / slideWidth
21+
})
22+
23+
const style = computed(() => ({
24+
height: `${slideHeight}px`,
25+
width: `${slideWidth}px`,
26+
transform: `translate(-50%, -50%) scale(${scale.value})`,
27+
}))
28+
</script>
29+
30+
<template>
31+
<div ref="root" class="slide-container">
32+
<div class="slide-content" :style="style">
33+
<slot />
34+
</div>
35+
<slot name="controls" />
36+
</div>
37+
</template>
38+
39+
<style lang="postcss">
40+
.slide-container {
41+
@apply relative overflow-hidden;
42+
}
43+
44+
.slide-content {
45+
@apply relative overflow-hidden bg-main absolute left-1/2 top-1/2;
46+
}
47+
</style>

.vitepress/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function removeHash(link: string) {
77
}
88

99
function getGuideTitle(id: string) {
10-
return Guides.find(g => g.link.endsWith(id))?.text ?? Advanced.find(g => g.link.endsWith(id))?.text ?? id
10+
return Guides.find(g => g.link.endsWith(`/${id}`))?.text ?? Advanced.find(g => g.link.endsWith(id))?.text ?? id
1111
}
1212

1313
export function resolveLink(link: string): {

builtin/cli.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ npm run slidev -- --remote --port 8080 --open
7474
- `--dark` (`boolean`, 默认值: `false`): 导出为暗黑模式
7575
- `--with-clicks`, `-c` (`boolean`, 默认值: `false`): 为每次点击分别导出 (参考 https://cn.sli.dev/guide/animations.html#click-animations).
7676
- `--theme`, `-t` (`string`): 覆盖文件中设定的主题
77+
- `--omit-background` (`boolean`, default: `false`): 不导出浏览器默认的背景色
7778

7879
## `slidev format [entry]` {#format}
7980

components.d.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ declare module 'vue' {
99
export interface GlobalComponents {
1010
AddonGallery: typeof import('./.vitepress/theme/components/AddonGallery.vue')['default']
1111
AddonInfo: typeof import('./.vitepress/theme/components/AddonInfo.vue')['default']
12-
Arrow: typeof import('./.vitepress/@slidev/client/builtin/Arrow.vue')['default']
13-
AutoFitText: typeof import('./.vitepress/@slidev/client/builtin/AutoFitText.vue')['default']
12+
Arrow: typeof import('./node_modules/@slidev/client/builtin/Arrow.vue')['default']
13+
AutoFitText: typeof import('./node_modules/@slidev/client/builtin/AutoFitText.vue')['default']
1414
'Carbon:chevronLeft': typeof import('~icons/carbon/chevron-left')['default']
1515
'Carbon:chevronRight': typeof import('~icons/carbon/chevron-right')['default']
1616
'Carbon:close': typeof import('~icons/carbon/close')['default']
@@ -39,7 +39,7 @@ declare module 'vue' {
3939
CarbonUserAvatar: typeof import('~icons/carbon/user-avatar')['default']
4040
CarbonUserSpeaker: typeof import('~icons/carbon/user-speaker')['default']
4141
CarbonVideo: typeof import('~icons/carbon/video')['default']
42-
CodeBlockWrapper: typeof import('./.vitepress/@slidev/client/builtin/CodeBlockWrapper.vue')['default']
42+
CodeBlockWrapper: typeof import('./node_modules/@slidev/client/builtin/CodeBlockWrapper.vue')['default']
4343
CodiconAdd: typeof import('~icons/codicon/add')['default']
4444
CodiconEye: typeof import('~icons/codicon/eye')['default']
4545
CodiconLock: typeof import('~icons/codicon/lock')['default']
@@ -52,37 +52,44 @@ declare module 'vue' {
5252
FeaturesAnimationInner: typeof import('./.vitepress/theme/components/FeaturesAnimationInner.vue')['default']
5353
FeaturesOverview: typeof import('./.vitepress/theme/components/FeaturesOverview.vue')['default']
5454
FeatureTag: typeof import('./.vitepress/theme/components/FeatureTag.vue')['default']
55+
KaTexBlockWrapper: typeof import('./node_modules/@slidev/client/builtin/KaTexBlockWrapper.vue')['default']
5556
LandingPage: typeof import('./.vitepress/theme/components/LandingPage.vue')['default']
5657
Layout: typeof import('./.vitepress/theme/components/Layout.vue')['default']
57-
Link: typeof import('./.vitepress/@slidev/client/builtin/Link.vue')['default']
58+
LightOrDark: typeof import('./node_modules/@slidev/client/builtin/LightOrDark.vue')['default']
59+
Link: typeof import('./node_modules/@slidev/client/builtin/Link.vue')['default']
5860
LinkCard: typeof import('./.vitepress/theme/components/LinkCard.vue')['default']
5961
LinkInline: typeof import('./.vitepress/theme/components/LinkInline.vue')['default']
6062
LogosVue: typeof import('~icons/logos/vue')['default']
6163
MdiAccountCircle: typeof import('~icons/mdi/account-circle')['default']
62-
Mermaid: typeof import('./.vitepress/@slidev/client/builtin/Mermaid.vue')['default']
63-
Monaco: typeof import('./.vitepress/@slidev/client/builtin/Monaco.vue')['default']
64-
PlantUml: typeof import('./.vitepress/@slidev/client/builtin/PlantUml.vue')['default']
65-
RenderWhen: typeof import('./.vitepress/@slidev/client/builtin/RenderWhen.vue')['default']
64+
Mermaid: typeof import('./node_modules/@slidev/client/builtin/Mermaid.vue')['default']
65+
Monaco: typeof import('./node_modules/@slidev/client/builtin/Monaco.vue')['default']
66+
PlantUml: typeof import('./node_modules/@slidev/client/builtin/PlantUml.vue')['default']
67+
PoweredBySlidev: typeof import('./node_modules/@slidev/client/builtin/PoweredBySlidev.vue')['default']
68+
RenderWhen: typeof import('./node_modules/@slidev/client/builtin/RenderWhen.vue')['default']
6669
RouterLink: typeof import('vue-router')['RouterLink']
6770
RouterView: typeof import('vue-router')['RouterView']
6871
SeeAlso: typeof import('./.vitepress/theme/components/SeeAlso.vue')['default']
72+
ShikiMagicMove: typeof import('./node_modules/@slidev/client/builtin/ShikiMagicMove.vue')['default']
6973
ShowCaseInfo: typeof import('./.vitepress/theme/components/ShowCaseInfo.vue')['default']
7074
ShowCases: typeof import('./.vitepress/theme/components/ShowCases.vue')['default']
7175
SimpleIconsGithub: typeof import('~icons/simple-icons/github')['default']
7276
SimpleIconsNpm: typeof import('~icons/simple-icons/npm')['default']
73-
SlideCurrentNo: typeof import('./.vitepress/@slidev/client/builtin/SlideCurrentNo.vue')['default']
74-
SlidesTotal: typeof import('./.vitepress/@slidev/client/builtin/SlidesTotal.vue')['default']
75-
Starport: typeof import('vue-starport')['Starport']
76-
StarportCarrier: typeof import('vue-starport')['StarportCarrier']
77+
SlideContainer: typeof import('./.vitepress/theme/components/SlideContainer.vue')['default']
78+
SlideCurrentNo: typeof import('./node_modules/@slidev/client/builtin/SlideCurrentNo.vue')['default']
79+
SlidesTotal: typeof import('./node_modules/@slidev/client/builtin/SlidesTotal.vue')['default']
80+
SlidevVideo: typeof import('./node_modules/@slidev/client/builtin/SlidevVideo.vue')['default']
7781
ThemeGallery: typeof import('./.vitepress/theme/components/ThemeGallery.vue')['default']
7882
ThemeInfo: typeof import('./.vitepress/theme/components/ThemeInfo.vue')['default']
7983
TheTweet: typeof import('./.vitepress/theme/components/TheTweet.vue')['default']
80-
Toc: typeof import('./.vitepress/@slidev/client/builtin/Toc.vue')['default']
81-
TocList: typeof import('./.vitepress/@slidev/client/builtin/TocList.vue')['default']
82-
Transform: typeof import('./.vitepress/@slidev/client/builtin/Transform.vue')['default']
83-
Tweet: typeof import('./.vitepress/@slidev/client/builtin/Tweet.vue')['default']
84+
Toc: typeof import('./node_modules/@slidev/client/builtin/Toc.vue')['default']
85+
TocList: typeof import('./node_modules/@slidev/client/builtin/TocList.vue')['default']
86+
Transform: typeof import('./node_modules/@slidev/client/builtin/Transform.vue')['default']
87+
Tweet: typeof import('./node_modules/@slidev/client/builtin/Tweet.vue')['default']
8488
TwemojiCatWithTearsOfJoy: typeof import('~icons/twemoji/cat-with-tears-of-joy')['default']
8589
UimRocket: typeof import('~icons/uim/rocket')['default']
86-
Youtube: typeof import('./.vitepress/@slidev/client/builtin/Youtube.vue')['default']
90+
VClickGap: typeof import('./node_modules/@slidev/client/builtin/VClickGap.vue')['default']
91+
VDrag: typeof import('./node_modules/@slidev/client/builtin/VDrag.vue')['default']
92+
VDragArrow: typeof import('./node_modules/@slidev/client/builtin/VDragArrow.vue')['default']
93+
Youtube: typeof import('./node_modules/@slidev/client/builtin/Youtube.vue')['default']
8794
}
8895
}

custom/config-vite.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Slidev 已经内置了以下插件:
2424
```ts twoslash
2525
/// <reference types="@slidev/types" />
2626
import type MarkdownIt from 'markdown-it'
27-
declare const MyPlugin: (md: MarkdownIt) => void
27+
declare const MyPlugin: (md: any) => void
2828
// ---cut---
2929
import { defineConfig } from 'vite'
3030

@@ -37,7 +37,7 @@ export default defineConfig({
3737
/* markdown-it 的选项 */
3838
markdownItSetup(md) {
3939
/* 自定义的 markdown-it 插件 */
40-
md.use(MyPlugin/* ... */)
40+
md.use(MyPlugin, /* ... */)
4141
},
4242
},
4343
/* 其他插件的选项 */

features/slide-scope-style.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
relates:
3-
- Vue 的 <style scoped>: https://vue-loader.vuejs.org/guide/scoped-css.html
3+
- Vue 的 Scoped CSS: https://vue-loader.vuejs.org/guide/scoped-css.html
44
- UnoCSS directives: https://unocss.dev/transformers/directives
55
tags: [样式, 语法]
66
description: |

guide/animations.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ Slidev 内置了 [@vueuse/motion](https://motion.vueuse.org/)。你可以使用
352352

353353
了解更多:[Demo](https://sli.dev/demo/starter/10) | [@vueuse/motion](https://motion.vueuse.org/) | [v-motion](https://motion.vueuse.org/features/directive-usage) | [Presets](https://motion.vueuse.org/features/presets)
354354

355-
## Slide Transitions
355+
## Slide Transitions {#slide-transitions}
356356

357357
<div id="pages-transitions" />
358358

guide/exporting.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,3 +178,21 @@ $ slidev export --executable-path [path_to_chromium]
178178
```bash
179179
$ slidev export --with-toc
180180
```
181+
182+
### Omit Background
183+
184+
When exporting to PNGs, you can remove the default browser background by passing `--omit-background`:
185+
186+
```bash
187+
$ slidev export --omit-background
188+
```
189+
190+
The default browser background is the white background visible on all browser windows and is different than other backgrounds applied throughout the application using CSS styling. [See Playwright docs](https://playwright.dev/docs/api/class-page#page-screenshot-option-omit-background). You will then need to apply additional CSS styling to the application to reveal the transparency.
191+
192+
Here is a basic example that covers all backgrounds in the application:
193+
194+
```css
195+
* {
196+
background: transparent !important;
197+
}
198+
```

guide/hosting.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ $ slidev build --base /talks/my-cool-talk/
2626

2727
参阅 [Vite 文档](https://cn.vitejs.dev/guide/build.html#public-base-path) 了解更多细节。
2828

29-
### 输出目录 {#output}
29+
### 输出目录 {#output-directory}
3030

3131
你可以通过 `--out` 选项更改输出目录:
3232

guide/syntax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ src: ./pages/4.md # 本页只包含 frontmatter
9191

9292
## 备注 {#notes}
9393

94-
每张幻灯片的末尾的注释块(若有),将被视为幻灯片的备注。它们将在 [演讲者模式](../guide/ui#presenter-mode) 中显示,以供您在演示过程中参考。
94+
每张幻灯片的末尾的注释块(若有),将被视为幻灯片的备注。它们将在 <LinkInline link="guide/ui#presenter-mode" /> 中显示,以供您在演示过程中参考。
9595

9696
```md {9,19-21}
9797
---

guide/why.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ Slidev 以 Web 为平台的展示您的幻灯片,因此任何可以在 Web 应
105105

106106
## 尝试使用 Slidev
107107

108-
动手尝试胜于千言万语。查看 <LinkInline link="guide/index"/> 指南,即刻创建您的第一个 Slidev 项目。
108+
动手尝试胜于千言万语。查看 <LinkInline link="guide/"/> 指南,即刻创建您的第一个 Slidev 项目。
109109

110110
或者您也可以通过下方的视频进行快速预览:
111111

0 commit comments

Comments
 (0)