diff --git a/template/.vitepress/theme/index.js b/template/.vitepress/theme/index.js index 8ea44ecb72d1..3e14542a6843 100644 --- a/template/.vitepress/theme/index.js +++ b/template/.vitepress/theme/index.js @@ -1,25 +1,29 @@ // https://vitepress.dev/guide/custom-theme -<% if (!defaultTheme) { %>import Layout from './Layout.vue' +<% if (!defaultTheme) { %>import Layout from './Layout.vue'<% if (useTs) { %> +import type { Theme } from 'vitepress'<% } %> import './style.css' -export default { +<% if (!useTs) { %>/** @type {import('vitepress').Theme} */ +<% } %>export default { Layout, enhanceApp({ app, router, siteData }) { // ... } -} -<% } else { %>import { h } from 'vue' -import Theme from 'vitepress/theme' +}<% if (useTs) { %> satisfies Theme<% } %> +<% } else { %>import { h } from 'vue'<% if (useTs) { %> +import type { Theme } from 'vitepress'<% } %> +import DefaultTheme from 'vitepress/theme' import './style.css' -export default { - extends: Theme, +<% if (!useTs) { %>/** @type {import('vitepress').Theme} */ +<% } %>export default { + extends: DefaultTheme, Layout: () => { - return h(Theme.Layout, null, { + return h(DefaultTheme.Layout, null, { // https://vitepress.dev/guide/extending-default-theme#layout-slots }) }, enhanceApp({ app, router, siteData }) { // ... } -}<% } %> +}<% if (useTs) { %> satisfies Theme<% } %><% } %>