File tree 4 files changed +31
-17
lines changed
packages/@vuepress/core/src
4 files changed +31
-17
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,15 @@ const log = debug('vuepress:core/app')
10
10
export const createAppPages = async ( app : App ) : Promise < Page [ ] > => {
11
11
log ( 'createAppPages start' )
12
12
13
- // resolve page file paths according to the page patterns
14
- const pagePaths = await globby ( app . options . pagePatterns , {
13
+ // resolve page absolute file paths according to the page patterns
14
+ const pageFilePaths = await globby ( app . options . pagePatterns , {
15
+ absolute : true ,
15
16
cwd : app . dir . source ( ) ,
16
17
} )
17
18
18
19
// create pages from files
19
20
const pages = await Promise . all (
20
- pagePaths . map ( ( filePath ) => createPage ( app , { filePath } ) )
21
+ pageFilePaths . map ( ( filePath ) => createPage ( app , { filePath } ) )
21
22
)
22
23
23
24
// if there is no 404 page, add one
Original file line number Diff line number Diff line change @@ -22,17 +22,8 @@ export const resolvePageFilePath = ({
22
22
}
23
23
}
24
24
25
- // absolute file path
26
- if ( path . isAbsolute ( filePath ) ) {
27
- return {
28
- filePath,
29
- filePathRelative : path . relative ( app . dir . source ( ) , filePath ) ,
30
- }
31
- }
32
-
33
- // relative file path
34
25
return {
35
- filePath : app . dir . source ( filePath ) ,
36
- filePathRelative : filePath ,
26
+ filePath,
27
+ filePathRelative : path . relative ( app . dir . source ( ) , filePath ) ,
37
28
}
38
29
}
Original file line number Diff line number Diff line change @@ -10,11 +10,12 @@ export const resolvePageOptions = async ({
10
10
app : App
11
11
optionsRaw : PageOptions
12
12
} ) : Promise < PageOptions > => {
13
+ // avoid mutating the original options object provided by user
13
14
const options = { ...optionsRaw }
14
15
15
16
// plugin hook: extendsPageOptions
16
17
const extendsPageOptions = await app . pluginApi . hooks . extendsPageOptions . process (
17
- optionsRaw ,
18
+ options ,
18
19
app
19
20
)
20
21
extendsPageOptions . forEach ( ( item ) => Object . assign ( options , item ) )
Original file line number Diff line number Diff line change @@ -135,8 +135,29 @@ export interface Page<T extends PageData = PageData> extends PageData {
135
135
* Options to create vuepress page
136
136
*/
137
137
export interface PageOptions {
138
- path ?: string
138
+ /**
139
+ * If `filePath` is not set, this option will be used as the raw
140
+ * markdown content of the page.
141
+ *
142
+ * If `filePath` is set, this option will be ignored, while the
143
+ * content of the file will be used.
144
+ */
145
+ content ?: string
146
+
147
+ /**
148
+ * Absolute file path of the markdown source file.
149
+ */
139
150
filePath ?: string
151
+
152
+ /**
153
+ * Default frontmatter of the page, which could be overridden by
154
+ * the frontmatter of the markdown content.
155
+ */
140
156
frontmatter ?: PageFrontmatter
141
- content ?: string
157
+
158
+ /**
159
+ * If this option is set, it will be used as the final route path
160
+ * of the page, ignoring the relative path and permalink.
161
+ */
162
+ path ?: string
142
163
}
You can’t perform that action at this time.
0 commit comments