Skip to content

Commit 56b3ce5

Browse files
userquinbrc-dd
andauthoredOct 22, 2023
feat(template): add types for theme config (#3122)
Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com>
1 parent 432c548 commit 56b3ce5

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed
 

‎template/.vitepress/theme/index.js

+13-9
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
// https://vitepress.dev/guide/custom-theme
2-
<% if (!defaultTheme) { %>import Layout from './Layout.vue'
2+
<% if (!defaultTheme) { %>import Layout from './Layout.vue'<% if (useTs) { %>
3+
import type { Theme } from 'vitepress'<% } %>
34
import './style.css'
45

5-
export default {
6+
<% if (!useTs) { %>/** @type {import('vitepress').Theme} */
7+
<% } %>export default {
68
Layout,
79
enhanceApp({ app, router, siteData }) {
810
// ...
911
}
10-
}
11-
<% } else { %>import { h } from 'vue'
12-
import Theme from 'vitepress/theme'
12+
}<% if (useTs) { %> satisfies Theme<% } %>
13+
<% } else { %>import { h } from 'vue'<% if (useTs) { %>
14+
import type { Theme } from 'vitepress'<% } %>
15+
import DefaultTheme from 'vitepress/theme'
1316
import './style.css'
1417

15-
export default {
16-
extends: Theme,
18+
<% if (!useTs) { %>/** @type {import('vitepress').Theme} */
19+
<% } %>export default {
20+
extends: DefaultTheme,
1721
Layout: () => {
18-
return h(Theme.Layout, null, {
22+
return h(DefaultTheme.Layout, null, {
1923
// https://vitepress.dev/guide/extending-default-theme#layout-slots
2024
})
2125
},
2226
enhanceApp({ app, router, siteData }) {
2327
// ...
2428
}
25-
}<% } %>
29+
}<% if (useTs) { %> satisfies Theme<% } %><% } %>

0 commit comments

Comments
 (0)