Skip to content

Commit

Permalink
refactor: move default theme to 'vitepress/theme'
Browse files Browse the repository at this point in the history
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'.
  • Loading branch information
yyx990803 committed Jan 12, 2021
1 parent 4072dc5 commit a79e1e1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
5 changes: 1 addition & 4 deletions src/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
export type { Router, Route } from './app/router'

// theme types
export * from './app/theme'
export type { Theme, EnhanceAppContext } from './app/theme'

// composables
export { useRouter, useRoute } from './app/router'
Expand All @@ -24,6 +24,3 @@ import { ComponentOptions } from 'vue'
import _Debug from './app/components/Debug.vue'
const Debug = _Debug as ComponentOptions
export { Debug }

// default theme
export { default as DefaultTheme } from './theme-default'
4 changes: 4 additions & 0 deletions src/node/alias.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ export function resolveAliases(
find: /^vitepress$/,
replacement: path.join(__dirname, '../client/index')
},
{
find: /^vitepress\/theme$/,
replacement: path.join(__dirname, '../client/theme-default/index')
},
// alias for local linked development
{ find: /^vitepress\//, replacement: PKG_ROOT + '/' },
// make sure it always use the same vue dependency that comes with
Expand Down
3 changes: 3 additions & 0 deletions theme.d.ts
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 2 deletions types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export * from './shared'
export * from '../dist/node/index'
export * from '../dist/client/app/exports'
export * from '../dist/client/index'
export * from '../dist/client/theme-default/config'
export { default as defaultTheme } from '../dist/client/theme-default/index'

0 comments on commit a79e1e1

Please sign in to comment.