File tree Expand file tree Collapse file tree 6 files changed +42
-44
lines changed
Expand file tree Collapse file tree 6 files changed +42
-44
lines changed Load Diff This file was deleted.
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1+ // exports in this file are exposed to themes and md files via 'vitepress'
2+ // so the user can do `import { useRoute, useSiteData } from 'vitepress'`
3+
4+ // generic types
5+ export type { Router , Route } from './app/router'
6+
7+ // theme types
8+ export * from './app/theme'
9+
10+ // composables
11+ export { useRouter , useRoute } from './app/router'
12+ export { useSiteData } from './app/composables/siteData'
13+ export { useSiteDataByRoute } from './app/composables/siteDataByRoute'
14+ export { usePageData } from './app/composables/pageData'
15+ export { useFrontmatter } from './app/composables/frontmatter'
16+
17+ // utilities
18+ export { inBrowser , joinPath } from './app/utils'
19+
20+ // components
21+ export { Content } from './app/components/Content'
22+
23+ import { ComponentOptions } from 'vue'
24+ import _Debug from './app/components/Debug.vue'
25+ const Debug = _Debug as ComponentOptions
26+ export { Debug }
27+
28+ // default theme
29+ export { default as DefaultTheme } from './theme-default'
Original file line number Diff line number Diff line change 88 "lib" : [" ESNext" , " DOM" ],
99 "types" : [" vite" ],
1010 "paths" : {
11- "/@theme/*" : [" theme-default/*" ],
12- "/@default-theme/*" : [" theme-default/*" ],
1311 "/@shared/*" : [" shared/*" ],
1412 "/@types/*" : [" ../../types/*" ],
15- "vitepress" : [" app/exports.ts" ]
13+ "/@theme/*" : [" theme-default/*" ],
14+ "vitepress" : [" index.ts" ]
1615 }
1716 },
1817 "include" : [
Original file line number Diff line number Diff line change @@ -17,20 +17,14 @@ export const DEFAULT_THEME_PATH = path.join(
1717export const SITE_DATA_ID = '@siteData'
1818export const SITE_DATA_REQUEST_PATH = '/' + SITE_DATA_ID
1919
20- // this is a path resolver that is passed to vite
21- // so that we can resolve custom requests that start with /@app or /@theme
22- // we also need to map file paths back to their public served paths so that
23- // vite HMR can send the correct update notifications to the client.
2420export function resolveAliases (
2521 root : string ,
2622 themeDir : string ,
2723 userConfig : UserConfig
2824) : AliasOptions {
2925 const paths : Record < string , string > = {
3026 ...userConfig . alias ,
31- '/@app' : APP_PATH ,
3227 '/@theme' : themeDir ,
33- '/@default-theme' : DEFAULT_THEME_PATH ,
3428 '/@shared' : SHARED_PATH ,
3529 [ SITE_DATA_ID ] : SITE_DATA_REQUEST_PATH
3630 }
@@ -40,7 +34,10 @@ export function resolveAliases(
4034 find : p ,
4135 replacement : paths [ p ]
4236 } ) ) ,
43- { find : / ^ v i t e p r e s s $ / , replacement : `${ APP_PATH } /exports.js` }
37+ {
38+ find : / ^ v i t e p r e s s $ / ,
39+ replacement : path . join ( __dirname , '../client/index' )
40+ }
4441 ]
4542
4643 let isLinked = false
Original file line number Diff line number Diff line change @@ -77,12 +77,16 @@ export function createVitePressPlugin(
7777
7878 configureServer ( server ) {
7979 // serve our index.html after vite history fallback
80- const indexPath = `/@fs/${ path . join ( APP_PATH , 'index.html' ) } `
8180 return ( ) => {
8281 // @ts -ignore
83- server . app . use ( ( req , _ , next ) => {
82+ server . app . use ( ( req , res , next ) => {
8483 if ( req . url ! . endsWith ( '.html' ) ) {
85- req . url = indexPath
84+ res . statusCode = 200
85+ res . end (
86+ `<div id="app"></div>\n` +
87+ `<script type="module" src="/@fs/${ APP_PATH } /index.js"></script>`
88+ )
89+ return
8690 }
8791 next ( )
8892 } )
You can’t perform that action at this time.
0 commit comments