Skip to content

Commit dd30de5

Browse files
Merge pull request #53 from slidevjs/sync-9477d414
docs(en): merge docs/main into docs-de/main @ 9477d41
2 parents 7570f62 + acfc30a commit dd30de5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+2362
-1314
lines changed

.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
shamefully-hoist=true
2+
strict-peer-dependencies=false

.vitepress/config.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,30 @@ const Guide = [
5757

5858
const Theme = [
5959
{
60-
text: 'Thema benutzen',
60+
text: 'Theme benutzen',
6161
link: '/themes/use',
6262
},
6363
{
6464
text: 'Themen Gallerie',
6565
link: '/themes/gallery',
6666
},
6767
{
68-
text: 'Thema erstellen',
68+
text: 'Theme erstellen',
6969
link: '/themes/write-a-theme',
7070
},
7171
]
7272

73+
const Addon = [
74+
{
75+
text: 'Addon benutzen',
76+
link: '/addons/use',
77+
},
78+
{
79+
text: 'Addon erstellen',
80+
link: '/addons/write-an-addon',
81+
},
82+
]
83+
7384
const Translations = [
7485
{
7586
text: 'Deutsch',
@@ -157,6 +168,10 @@ const Customizations = [
157168
text: 'Mermaid konfigurieren',
158169
link: '/custom/config-mermaid',
159170
},
171+
{
172+
text: 'Parser konfigurieren',
173+
link: '/custom/config-parser',
174+
},
160175
{
161176
text: 'Shortcuts konfigurieren',
162177
link: '/custom/config-shortcuts',
@@ -166,7 +181,7 @@ const Customizations = [
166181
link: '/custom/vue-context',
167182
},
168183
{
169-
text: 'Globale Ebnen',
184+
text: 'Globale Ebenen',
170185
link: '/custom/global-layers',
171186
}
172187
]
@@ -195,6 +210,10 @@ const slidebars = [
195210
text: 'Themen',
196211
children: Theme,
197212
},
213+
{
214+
text: 'Addons',
215+
children: Addon,
216+
},
198217
{
199218
text: 'Individualisierung',
200219
children: Customizations,
@@ -241,7 +260,8 @@ module.exports = {
241260
editLinkText: 'Schlage Verbesserungen an dieser Seite vor',
242261

243262
algolia: {
244-
apiKey: '1a5c5a504139c58f428974c78c55291d',
263+
appId: 'LCBV6MIFS6',
264+
apiKey: '1ff173fe73b20edc962c1c24c0b1c160',
245265
indexName: 'slidev',
246266
searchParameters: {
247267
// for translations maintainers: change the filter to your locale code (subdomain name)
@@ -258,6 +278,10 @@ module.exports = {
258278
text: 'Thema',
259279
items: Theme,
260280
},
281+
{
282+
text: 'Addon',
283+
items: Addon,
284+
},
261285
{
262286
text: 'Individualisieren',
263287
items: Customizations,
@@ -275,6 +299,7 @@ module.exports = {
275299
sidebar: {
276300
'/guide/': slidebars,
277301
'/themes/': slidebars,
302+
'/addons/': slidebars,
278303
'/custom/': slidebars,
279304
'/builtin/': slidebars,
280305
'/resources/': slidebars,

.vitepress/showcases.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,40 @@ export const showcases: ShowCaseInfo[] = [
120120
at: 'Internal Tech Talk',
121121
datetime: '2022-03-11',
122122
},
123+
{
124+
title: 'OpenFunction 202',
125+
cover: 'https://s2.loli.net/2022/05/22/4zsCnkQRFoAU1E5.png',
126+
author: {
127+
name: 'Haili Zhang',
128+
link: 'https://github.com/webup',
129+
},
130+
slidesLink: 'https://openfunction-talks.netlify.app/2022/202-node-async/',
131+
sourceLink: 'https://github.com/webup/openfunction-talks/tree/main/202-node-async',
132+
at: 'OpenFunction Tutorial Sharing',
133+
datetime: '2022-05-08',
134+
},
135+
{
136+
title: 'Is it Okay to Pursue Functional Programming on Frontend?',
137+
author: {
138+
name: 'Minsu Kim , Changhui Lee',
139+
},
140+
at: '2022 JSConf Korea',
141+
slidesLink: 'https://moonlit-nougat-422445.netlify.app/1',
142+
sourceLink: 'https://github.com/alstn2468/2022-jsconf-presentation',
143+
cover: 'https://raw.githubusercontent.com/alstn2468/2022-jsconf-presentation/main/public/images/og.png',
144+
datetime: '2022-09-16',
145+
},
146+
{
147+
title: 'Blazing slidev ppt template with naive-ui',
148+
author: {
149+
name: 'godkun',
150+
},
151+
at: 'personal sharing',
152+
slidesLink: 'https://ppt.godkun.top',
153+
sourceLink: 'https://github.com/godkun/ppt-template',
154+
cover: 'https://github.com/godkun/ppt-template/raw/main/public/show.gif',
155+
datetime: '2022-10-24',
156+
},
123157
// Add yours here!
124158
{
125159
title: 'Yours?',

.vitepress/theme/Layout.vue

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,19 +50,17 @@
5050

5151
<!-- <Debug /> -->
5252

53-
<ClientOnly>
53+
<!-- <ClientOnly>
5454
<WorkingInProgress />
55-
</ClientOnly>
55+
</ClientOnly> -->
5656
</template>
5757

5858
<script setup lang="ts">
5959
import { ref, computed, watch, defineAsyncComponent } from 'vue'
6060
import {
6161
useRoute,
62-
useSiteData,
63-
useSiteDataByRoute,
62+
useData,
6463
} from 'vitepress'
65-
import type { DefaultTheme } from './config'
6664
6765
// components
6866
import NavBar from './components/NavBar.vue'
@@ -72,8 +70,7 @@ const Home = defineAsyncComponent(() => import('./components/Home.vue'))
7270
7371
// generic state
7472
const route = useRoute()
75-
const siteData = useSiteData<DefaultTheme.Config>()
76-
const siteRouteData = useSiteDataByRoute()
73+
const {site: siteData} = useData()
7774
const theme = computed(() => siteData.value.themeConfig)
7875
7976
const AlgoliaSearchBox = defineAsyncComponent(
@@ -87,7 +84,7 @@ const enableHome = computed(() => !!route.data.frontmatter.home)
8784
8885
// navbar
8986
const showNavbar = computed(() => {
90-
const { themeConfig } = siteRouteData.value
87+
const { themeConfig } = siteData.value
9188
const { frontmatter } = route.data
9289
if (frontmatter.navbar === false || themeConfig.navbar === false)
9390
return false
@@ -107,7 +104,7 @@ const openSideBar = ref(false)
107104
108105
const showSidebar = computed(() => {
109106
const { frontmatter } = route.data
110-
const { themeConfig } = siteRouteData.value
107+
const { themeConfig } = siteData.value
111108
return (
112109
!frontmatter.home
113110
&& frontmatter.sidebar !== false

.vitepress/theme/NotFound.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,18 @@
22
<div class="theme">
33
<h1>404</h1>
44
<blockquote>{{ getMsg() }}</blockquote>
5-
<a :href="$site.base" aria-label="go to home">Zurück zum Start</a>
5+
<a :href="site.base" aria-label="go to home">Zurück zum Start</a>
66
</div>
77
</template>
88

99
<script setup lang="ts">
10+
import { useData } from 'vitepress';
11+
12+
const {site} = useData()
1013
const msgs = [
1114
"Hier ist nichts.",
1215
"Wie sind wir denn hier hin gekommen?",
13-
// 'That\'s a Four-Oh-Four.',
16+
"Ups - 404",
1417
"Sieht aus, als wären ein paar Links kaputt.",
1518
];
1619

.vitepress/theme/components/AlgoliaSearchBox.vue

Lines changed: 59 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -4,126 +4,76 @@
44

55
<script setup lang="ts">
66
import '@docsearch/css'
7-
import { useRoute, useRouter } from 'vitepress'
8-
import { defineProps, getCurrentInstance, onMounted, watch } from 'vue'
97
import docsearch from '@docsearch/js'
10-
import type { DocSearchHit } from '@docsearch/react/dist/esm/types'
11-
import type { DefaultTheme } from '../config'
8+
import { onMounted } from 'vue'
9+
import { useRouter, useRoute, useData } from 'vitepress'
1210
13-
const props = defineProps<{
14-
options: DefaultTheme.AlgoliaSearchOptions
15-
}>()
16-
17-
const vm = getCurrentInstance()
18-
const route = useRoute()
1911
const router = useRouter()
20-
21-
watch(
22-
() => props.options,
23-
(value) => {
24-
update(value)
25-
},
26-
)
12+
const route = useRoute()
13+
const { theme, site } = useData()
2714
2815
onMounted(() => {
29-
initialize(props.options)
16+
initialize(theme.value.algolia)
3017
})
3118
32-
function isSpecialClick(event: MouseEvent) {
33-
return (
34-
event.button === 1
35-
|| event.altKey
36-
|| event.ctrlKey
37-
|| event.metaKey
38-
|| event.shiftKey
39-
)
40-
}
19+
// @ts-expect-error
20+
const docsearch$ = docsearch.default ?? docsearch
21+
type DocSearchProps = Parameters<typeof docsearch$>[0]
4122
42-
function getRelativePath(absoluteUrl: string) {
43-
const { pathname, hash } = new URL(absoluteUrl)
44-
45-
return pathname + hash
46-
}
23+
function initialize(userOptions: any) {
24+
// note: multi-lang search support is removed since the theme
25+
// doesn't support multiple locales as of now.
26+
const options = Object.assign<{}, {}, DocSearchProps>({}, userOptions, {
27+
container: '#docsearch',
28+
29+
navigator: {
30+
navigate({ itemUrl }: any) {
31+
const { pathname: hitPathname } = new URL(
32+
window.location.origin + itemUrl
33+
)
34+
35+
// router doesn't handle same-page navigation so we use the native
36+
// browser location API for anchor navigation
37+
if (route.path === hitPathname) {
38+
window.location.assign(window.location.origin + itemUrl)
39+
} else {
40+
router.go(itemUrl)
41+
}
42+
}
43+
},
4744
48-
function update(options: any) {
49-
if (vm && vm.vnode.el) {
50-
vm.vnode.el.innerHTML
51-
= '<div class="algolia-search-box" id="docsearch"></div>'
52-
initialize(options)
53-
}
45+
transformItems(items: any) {
46+
return items.map((item: any) => {
47+
return Object.assign({}, item, {
48+
url: getRelativePath(item.url)
49+
})
50+
})
51+
},
52+
53+
// @ts-expect-error vue-tsc thinks this should return Vue JSX but it returns the required React one
54+
hitComponent({ hit, children }) {
55+
return {
56+
__v: null,
57+
type: 'a',
58+
ref: undefined,
59+
constructor: undefined,
60+
key: undefined,
61+
props: { href: hit.url, children }
62+
}
63+
}
64+
})
65+
66+
docsearch$(options)
5467
}
5568
56-
function initialize(userOptions: any) {
57-
docsearch(
58-
Object.assign({}, userOptions, {
59-
container: '#docsearch',
60-
61-
searchParameters: Object.assign({}, userOptions.searchParameters),
62-
63-
navigator: {
64-
navigate: ({ suggestionUrl }: { suggestionUrl: string }) => {
65-
const { pathname: hitPathname } = new URL(
66-
window.location.origin + suggestionUrl,
67-
)
68-
69-
// Router doesn't handle same-page navigation so we use the native
70-
// browser location API for anchor navigation
71-
if (route.path === hitPathname)
72-
window.location.assign(window.location.origin + suggestionUrl)
73-
74-
else
75-
router.go(suggestionUrl)
76-
},
77-
},
78-
79-
transformItems: (items: DocSearchHit[]) => {
80-
return items.map((item) => {
81-
return Object.assign({}, item, {
82-
url: getRelativePath(item.url),
83-
})
84-
})
85-
},
86-
87-
hitComponent: ({
88-
hit,
89-
children,
90-
}: {
91-
hit: DocSearchHit
92-
children: any
93-
}) => {
94-
const relativeHit = hit.url.startsWith('http')
95-
? getRelativePath(hit.url as string)
96-
: hit.url
97-
98-
return {
99-
type: 'a',
100-
ref: undefined,
101-
constructor: undefined,
102-
key: undefined,
103-
props: {
104-
href: hit.url,
105-
onClick: (event: MouseEvent) => {
106-
if (isSpecialClick(event))
107-
return
108-
109-
// we rely on the native link scrolling when user is already on
110-
// the right anchor because Router doesn't support duplicated
111-
// history entries
112-
if (route.path === relativeHit)
113-
return
114-
115-
// if the hits goes to another page, we prevent the native link
116-
// behavior to leverage the Router loading feature
117-
if (route.path !== relativeHit)
118-
event.preventDefault()
119-
120-
router.go(relativeHit)
121-
},
122-
children,
123-
},
124-
}
125-
},
126-
}),
69+
function getRelativePath(absoluteUrl: string) {
70+
const { pathname, hash } = new URL(absoluteUrl)
71+
return (
72+
pathname.replace(
73+
/\.html$/,
74+
// @ts-expect-error
75+
site.value.cleanUrls === 'disabled' ? '.html' : ''
76+
) + hash
12777
)
12878
}
12979
</script>

0 commit comments

Comments
 (0)