File tree Expand file tree Collapse file tree 5 files changed +56
-48
lines changed Expand file tree Collapse file tree 5 files changed +56
-48
lines changed Original file line number Diff line number Diff line change 6
6
},
7
7
"dependencies" : {
8
8
"@vue/repl" : " ^0.4.7" ,
9
- "@vue/theme" : " ^0.1.20 " ,
10
- "vitepress" : " ^0.20.8 " ,
9
+ "@vue/theme" : " ^0.1.22 " ,
10
+ "vitepress" : " ^0.20.9 " ,
11
11
"vue" : " ^3.2.25"
12
12
},
13
13
"devDependencies" : {
Original file line number Diff line number Diff line change @@ -478,43 +478,6 @@ export const sidebar = {
478
478
export default defineConfig ( {
479
479
extends : baseConfig ,
480
480
481
- vite : {
482
- define : {
483
- __VUE_OPTIONS_API__ : false
484
- } ,
485
- optimizeDeps : {
486
- exclude : [ '@vue/repl' ]
487
- } ,
488
- // @ts -ignore
489
- ssr : {
490
- external : [ '@vue/repl' ]
491
- } ,
492
- server : {
493
- host : true ,
494
- fs : {
495
- // for when developing with locally linked theme
496
- allow : [ '../..' ]
497
- }
498
- } ,
499
- build : {
500
- minify : 'terser' ,
501
- chunkSizeWarningLimit : Infinity
502
- } ,
503
- json : {
504
- stringify : true
505
- }
506
- } ,
507
-
508
- vue : {
509
- template : {
510
- compilerOptions : {
511
- directiveTransforms : {
512
- focus : ( ) => ( { props : [ ] } )
513
- }
514
- }
515
- }
516
- } ,
517
-
518
481
lang : 'en-US' ,
519
482
title : 'Vue.js' ,
520
483
description : 'Vue.js - The Progressive JavaScript Framework' ,
@@ -570,5 +533,42 @@ export default defineConfig({
570
533
} ,
571
534
copyright : 'Copyright © 2014-2021 Evan You'
572
535
}
536
+ } ,
537
+
538
+ vite : {
539
+ define : {
540
+ __VUE_OPTIONS_API__ : false
541
+ } ,
542
+ optimizeDeps : {
543
+ exclude : [ '@vue/repl' ]
544
+ } ,
545
+ // @ts -ignore
546
+ ssr : {
547
+ external : [ '@vue/repl' ]
548
+ } ,
549
+ server : {
550
+ host : true ,
551
+ fs : {
552
+ // for when developing with locally linked theme
553
+ allow : [ '../..' ]
554
+ }
555
+ } ,
556
+ build : {
557
+ minify : 'terser' ,
558
+ chunkSizeWarningLimit : Infinity
559
+ } ,
560
+ json : {
561
+ stringify : true
562
+ }
563
+ } ,
564
+
565
+ vue : {
566
+ template : {
567
+ compilerOptions : {
568
+ directiveTransforms : {
569
+ focus : ( ) => ( { props : [ ] } )
570
+ }
571
+ }
572
+ }
573
573
}
574
574
} )
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
- import { APIGroup , data as apiIndex } from ' ./api.data'
2
+ // in .vue components or .md pages:
3
+ // named import "data" is the resolved static data
4
+ // can also import types for type consistency
5
+ import { data as apiIndex , APIGroup } from ' ./api.data'
3
6
import { ref , computed } from ' vue'
4
7
5
8
const query = ref (' ' )
Original file line number Diff line number Diff line change
1
+ // api.data.ts
2
+ // a file ending with data.(j|t)s will be evaluated in Node.js
1
3
import fs from 'fs'
2
4
import path from 'path'
3
5
import { sidebar } from '../.vitepress/config'
@@ -11,10 +13,13 @@ export interface APIGroup {
11
13
} [ ]
12
14
}
13
15
16
+ // declare resolved data type
14
17
export declare const data : APIGroup [ ]
15
18
16
19
export default {
20
+ // declare files that should trigger HMR
17
21
watch : './*.md' ,
22
+ // read from fs and generate the data
18
23
load ( ) : APIGroup [ ] {
19
24
return sidebar [ '/api/' ] . map ( ( group ) => ( {
20
25
text : group . text ,
You can’t perform that action at this time.
0 commit comments