Skip to content

Commit 3b7a515

Browse files
committed
fix: install theme globally for global installs
1 parent 88c244a commit 3b7a515

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

packages/slidev/node/themes.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import prompts from 'prompts'
22
import { parseNi, run } from '@antfu/ni'
3+
import isInstalledGlobally from 'is-installed-globally'
4+
import { underline } from 'kolorist'
35
import { resolveImportPath } from './utils'
46
import { isRelative } from './options'
57

@@ -48,13 +50,16 @@ export async function promptForThemeInstallation(name: string) {
4850
name: 'confirm',
4951
initial: 'Y',
5052
type: 'confirm',
51-
message: `The theme "${name}" was not found in your project, do you want to install it now?`,
53+
message: `The theme "${name}" was not found ${underline(isInstalledGlobally ? 'globally' : 'in your project')}, do you want to install it now?`,
5254
})
5355

5456
if (!confirm)
5557
return false
5658

57-
await run(parseNi, [name])
59+
if (isInstalledGlobally)
60+
await run(parseNi, ['-g', name])
61+
else
62+
await run(parseNi, [name])
5863

5964
return name
6065
}

packages/slidev/template.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ highlighter: shiki
1212
info: |
1313
## Slidev Starter Template
1414
Presentation slides for developers.
15-
15+
1616
Learn more at [Sli.dev](https://sli.dev)
1717
---
1818

@@ -40,7 +40,7 @@ The last comment block of each slide will be treated as slide notes. It will be
4040
# What is Slidev?
4141

4242
Slidev is a slides maker and presenter designed for developers, consist of the following features
43-
43+
4444
- 📝 **Text-based** - focus on the content with Markdown, and then style them later
4545
- 🎨 **Themable** - theme can be shared and used with npm packages
4646
- 🧑‍💻 **Developer Friendly** - code highlighting, live coding with autocompletion
@@ -71,7 +71,6 @@ h1 {
7171
}
7272
</style>
7373

74-
7574
---
7675

7776
# Navigation
@@ -87,14 +86,14 @@ Hover on the bottom-left corner to see the navigation's controls panel, [learn m
8786
| <kbd>up</kbd> | previous slide |
8887
| <kbd>down</kbd> | next slide |
8988

89+
<!-- https://sli.dev/guide/animations.html#click-animations -->
9090
<img
9191
v-click
9292
class="absolute -bottom-9 -left-7 w-80 opacity-50"
9393
src="https://sli.dev/assets/arrow-bottom-left.svg"
9494
/>
9595
<p v-after class="absolute bottom-23 left-45 opacity-30 transform -rotate-10">Here!</p>
9696

97-
9897
---
9998
layout: image-right
10099
image: https://source.unsplash.com/collection/94734566/1920x1080
@@ -104,6 +103,8 @@ image: https://source.unsplash.com/collection/94734566/1920x1080
104103

105104
Use code snippets and get the highlighting directly!
106105

106+
<!-- https://sli.dev/guide/syntax.html#line-highlighting -->
107+
107108
```ts {all|2|1-6|9|all}
108109
interface User {
109110
id: number
@@ -112,13 +113,15 @@ interface User {
112113
role: string
113114
}
114115

115-
function updateUser(id: number, update: Partial<User>) {
116+
function updateUser(id: number, update: User) {
116117
const user = getUser(id)
117118
const newUser = {...user, ...update}
118119
saveUser(id, newUser)
119120
}
120121
```
121122

123+
<arrow v-click="3" x1="400" y1="420" x2="230" y2="330" color="#564" width="3" arrowSize="1" />
124+
122125
---
123126

124127
# Components
@@ -128,7 +131,7 @@ function updateUser(id: number, update: Partial<User>) {
128131

129132
You can use Vue components directly inside your slides.
130133

131-
We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly use. And add your custom components are also super easy.
134+
We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that you can use directly. And adding your custom components is also super easy.
132135

133136
```html
134137
<Counter :count="10" />
@@ -137,7 +140,7 @@ We have provided a few built-in components like `<Tweet/>` and `<Youtube/>` that
137140
<!-- ./components/Counter.vue -->
138141
<Counter :count="10" m="t-4" />
139142

140-
Check out [the guides](https://sli.dev/custom/#components) for more.
143+
Check out [the guides](https://sli.dev/builtin/components.html) for more.
141144

142145
</div>
143146
<div>
@@ -250,11 +253,11 @@ const final = {
250253
}
251254
</script>
252255

253-
<div
256+
<div
254257
v-motion
255258
:initial="{ x:35, y: 40, opacity: 0}"
256259
:enter="{ y: 0, opacity: 1, transition: { delay: 3500 } }">
257-
260+
258261
[Learn More](https://sli.dev/guide/animations.html#motion)
259262

260263
</div>

scripts/publish.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import fs from 'fs-extra'
22
import { $ } from 'zx'
33

44
await fs.copyFile('README.md', 'packages/slidev/README.md')
5-
await $`npx pnpm -r publish --access public --no-git-checks`
5+
await $`npx pnpm -r publish --access public --no-git-checks --tag next`

0 commit comments

Comments
 (0)