refactor: move default theme to 'vitepress/theme'

Fixes the case when using a completely custom theme, importing anything
from vitepress causes the entire default theme to be imported too.

BREAKING CHANGE: the default theme is now exposed via 'vitepress/theme',
instead of a named export from 'vitepress'.
pull/207/head
Evan You 4 years ago
parent 4072dc5f7e
commit a79e1e1916

@ -5,7 +5,7 @@
export type { Router, Route } from './app/router' export type { Router, Route } from './app/router'
// theme types // theme types
export * from './app/theme' export type { Theme, EnhanceAppContext } from './app/theme'
// composables // composables
export { useRouter, useRoute } from './app/router' export { useRouter, useRoute } from './app/router'
@ -24,6 +24,3 @@ import { ComponentOptions } from 'vue'
import _Debug from './app/components/Debug.vue' import _Debug from './app/components/Debug.vue'
const Debug = _Debug as ComponentOptions const Debug = _Debug as ComponentOptions
export { Debug } export { Debug }
// default theme
export { default as DefaultTheme } from './theme-default'

@ -38,6 +38,10 @@ export function resolveAliases(
find: /^vitepress$/, find: /^vitepress$/,
replacement: path.join(__dirname, '../client/index') replacement: path.join(__dirname, '../client/index')
}, },
{
find: /^vitepress\/theme$/,
replacement: path.join(__dirname, '../client/theme-default/index')
},
// alias for local linked development // alias for local linked development
{ find: /^vitepress\//, replacement: PKG_ROOT + '/' }, { find: /^vitepress\//, replacement: PKG_ROOT + '/' },
// make sure it always use the same vue dependency that comes with // make sure it always use the same vue dependency that comes with

3
theme.d.ts vendored

@ -0,0 +1,3 @@
// so that users can do `import DefaultTheme from 'vitepress/theme'`
import DefaultTheme from './dist/client/theme-default/index'
export default DefaultTheme

3
types/index.d.ts vendored

@ -1,5 +1,4 @@
export * from './shared' export * from './shared'
export * from '../dist/node/index' export * from '../dist/node/index'
export * from '../dist/client/app/exports' export * from '../dist/client/index'
export * from '../dist/client/theme-default/config' export * from '../dist/client/theme-default/config'
export { default as defaultTheme } from '../dist/client/theme-default/index'

Loading…
Cancel
Save