Skip to content

Commit b92ca7f

Browse files
authored
docs: allow passing extra packages for ep-playground (element-plus#22979)
docs: allow passing extra packages
1 parent da1ac94 commit b92ca7f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

docs/.vitepress/vitepress/composables/use-playground.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,27 @@ export const usePlayground = (source: string) => {
1818

1919
const encoded = code ? utoa(JSON.stringify(originCode)) : ''
2020

21-
let link = `https://element-plus.run/`
21+
const link = new URL('https://element-plus.run/')
2222

2323
if (usePreview()) {
24-
link = `${link}?pr=${usePreviewPR()}`
24+
link.searchParams.append('pr', usePreviewPR())
2525
}
2626

2727
if (isDark.value) {
28-
link = `${link}${usePreview() ? '&' : '?'}theme=dark`
28+
link.searchParams.append('theme', 'dark')
29+
}
30+
31+
if (code.includes('@vueuse/core')) {
32+
link.searchParams.append('extra_packages', '@vueuse/core')
2933
}
3034

3135
if (code) {
32-
link += `#${encoded}`
36+
link.hash = encoded
3337
}
3438

3539
return {
3640
encoded,
37-
link,
41+
link: link.toString(),
3842
}
3943
}
4044

0 commit comments

Comments
 (0)