create-slidev 0.46.3 → 0.47.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build.mjs +20 -15
- package/package.json +1 -1
- package/template/package.json +1 -1
- package/template/slides.md +20 -25
- package/template/snippets/external.ts +9 -0
package/build.mjs
CHANGED
|
@@ -1,31 +1,36 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { fileURLToPath } from 'node:url'
|
|
2
|
+
import { dirname, resolve } from 'node:path'
|
|
3
|
+
import fs from 'fs-extra'
|
|
4
4
|
|
|
5
|
-
const __dirname =
|
|
5
|
+
const __dirname = fileURLToPath(new URL('.', import.meta.url))
|
|
6
6
|
const __templateDir = resolve(__dirname, 'template')
|
|
7
7
|
const __pagesDir = resolve(__templateDir, 'pages')
|
|
8
8
|
|
|
9
|
-
const shouldCreatePagesDict = () => !existsSync(__pagesDir)
|
|
9
|
+
const shouldCreatePagesDict = () => !fs.existsSync(__pagesDir)
|
|
10
10
|
|
|
11
11
|
// key: copy to (relative ./)
|
|
12
12
|
// value: origin (relative ./template)
|
|
13
13
|
const needCopyFiles = {
|
|
14
14
|
'slides.md': '../../../demo/starter/slides.md',
|
|
15
15
|
'pages/multiple-entries.md': '../../../demo/starter/pages/multiple-entries.md',
|
|
16
|
+
'snippets/external.ts': '../../../demo/starter/snippets/external.ts',
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
function main() {
|
|
19
|
+
async function main() {
|
|
19
20
|
if (shouldCreatePagesDict())
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
21
|
+
await fs.ensureDir(__pagesDir)
|
|
22
|
+
|
|
23
|
+
await Promise.all(
|
|
24
|
+
Object.keys(needCopyFiles).map(async (relativeTargetPath) => {
|
|
25
|
+
const sourcePath = resolve(__templateDir, needCopyFiles[relativeTargetPath])
|
|
26
|
+
const targetPath = resolve(__templateDir, relativeTargetPath)
|
|
27
|
+
if (fs.existsSync(targetPath))
|
|
28
|
+
await fs.rm(targetPath)
|
|
29
|
+
|
|
30
|
+
await fs.ensureDir(dirname(targetPath))
|
|
31
|
+
await fs.copy(sourcePath, targetPath)
|
|
32
|
+
}),
|
|
33
|
+
)
|
|
29
34
|
// eslint-disable-next-line no-console
|
|
30
35
|
console.log('done...')
|
|
31
36
|
}
|
package/package.json
CHANGED
package/template/package.json
CHANGED
package/template/slides.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
theme: seriph
|
|
3
3
|
background: https://source.unsplash.com/collection/94734566/1920x1080
|
|
4
4
|
class: text-center
|
|
5
|
-
highlighter:
|
|
5
|
+
highlighter: shiki
|
|
6
6
|
lineNumbers: false
|
|
7
7
|
info: |
|
|
8
8
|
## Slidev Starter Template
|
|
@@ -11,6 +11,8 @@ info: |
|
|
|
11
11
|
Learn more at [Sli.dev](https://sli.dev)
|
|
12
12
|
drawings:
|
|
13
13
|
persist: false
|
|
14
|
+
defaults:
|
|
15
|
+
foo: true
|
|
14
16
|
transition: slide-left
|
|
15
17
|
title: Welcome to Slidev
|
|
16
18
|
mdc: true
|
|
@@ -130,38 +132,31 @@ image: https://source.unsplash.com/collection/94734566/1920x1080
|
|
|
130
132
|
|
|
131
133
|
Use code snippets and get the highlighting directly, and even types hover![^1]
|
|
132
134
|
|
|
133
|
-
```ts {all|5|
|
|
134
|
-
// TwoSlash enables TypeScript hover information
|
|
135
|
-
//
|
|
136
|
-
|
|
137
|
-
return undefined as any
|
|
138
|
-
}
|
|
139
|
-
function saveUser(id: number, user: User) {
|
|
140
|
-
// ...
|
|
141
|
-
}
|
|
142
|
-
// ---cut---
|
|
143
|
-
interface User {
|
|
144
|
-
id: number
|
|
145
|
-
firstName: string
|
|
146
|
-
lastName: string
|
|
147
|
-
role: string
|
|
148
|
-
// ^?
|
|
149
|
-
}
|
|
135
|
+
```ts {all|5|7|7-8|10|all} twoslash
|
|
136
|
+
// TwoSlash enables TypeScript hover information
|
|
137
|
+
// and errors in markdown code blocks
|
|
138
|
+
// More at https://shiki.style/packages/twoslash
|
|
150
139
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
140
|
+
import { computed, ref } from 'vue'
|
|
141
|
+
|
|
142
|
+
const count = ref(0)
|
|
143
|
+
const doubled = computed(() => count.value * 2)
|
|
144
|
+
|
|
145
|
+
doubled.value = 2
|
|
156
146
|
```
|
|
157
147
|
|
|
158
|
-
<arrow v-click="[
|
|
148
|
+
<arrow v-click="[4, 5]" x1="350" y1="310" x2="195" y2="334" color="#953" width="2" arrowSize="1" />
|
|
149
|
+
|
|
150
|
+
<!-- This allow you to embed external code blocks -->
|
|
151
|
+
<<< @/snippets/external.ts#snippet
|
|
159
152
|
|
|
153
|
+
<!-- Footer -->
|
|
160
154
|
[^1]: [Learn More](https://sli.dev/guide/syntax.html#line-highlighting)
|
|
161
155
|
|
|
156
|
+
<!-- Inline style -->
|
|
162
157
|
<style>
|
|
163
158
|
.footnotes-sep {
|
|
164
|
-
@apply mt-
|
|
159
|
+
@apply mt-5 opacity-10;
|
|
165
160
|
}
|
|
166
161
|
.footnotes {
|
|
167
162
|
@apply text-sm opacity-75;
|