/
page.ts
180 lines (153 loc) · 3.77 KB
/
page.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
import type { MarkdownLink, MarkdownSfcBlocks } from '@vuepress/markdown'
import type { PageBase, PageData, PageFrontmatter } from '@vuepress/shared'
/**
* Vuepress Page
*/
export type Page<
ExtraPageData extends Record<any, any> = Record<never, never>,
ExtraPageFrontmatter extends Record<any, any> = Record<string, unknown>,
ExtraPageFields extends Record<any, any> = Record<never, never>
> = PageBase<ExtraPageFrontmatter> &
ExtraPageFields & {
/**
* Data of the page, which will be available in client code
*/
data: PageData<ExtraPageData, ExtraPageFrontmatter>
/**
* Raw Content of the page
*/
content: string
/**
* Rendered content of the page
*/
contentRendered: string
/**
* Date of the page, in 'yyyy-MM-dd' format
*
* @example '2020-09-09'
*/
date: string
/**
* Dependencies of the page
*/
deps: string[]
/**
* Links of the page
*/
links: MarkdownLink[]
/**
* Markdown env object of the page
*/
markdownEnv: Record<string, unknown>
/**
* Path of the page that inferred from file path
*
* If the page does not come from a file, it would be `null`
*
* @example '/guide/index.html'
*/
pathInferred: string | null
/**
* Locale path prefix of the page
*
* @example '/getting-started.html' -> '/'
* @example '/en/getting-started.html' -> '/en/'
* @example '/zh/getting-started.html' -> '/zh/'
*/
pathLocale: string
/**
* Permalink of the page
*
* If the page does not have a permalink, it would be `null`
*/
permalink: string | null
/**
* Custom data to be attached to the page route record of vue-router
*
* @see https://router.vuejs.org/api/#meta
*/
routeMeta: Record<string, unknown>
/**
* Extracted sfc blocks of the page
*/
sfcBlocks: MarkdownSfcBlocks
/**
* Slug of the page
*/
slug: string
/**
* Source file path
*
* If the page does not come from a file, it would be `null`
*/
filePath: string | null
/**
* Source file path relative to source directory
*
* If the page does not come from a file, it would be `null`
*/
filePathRelative: string | null
/**
* Component file path
*/
componentFilePath: string
/**
* Component file path relative to temp directory
*/
componentFilePathRelative: string
/**
* Component file chunk name
*
* Only take effect in webpack
*/
componentFileChunkName: string
/**
* Page data file path
*/
dataFilePath: string
/**
* Page data file path relative to temp directory
*/
dataFilePathRelative: string
/**
* Page data file chunk name
*
* Only take effect in webpack
*/
dataFileChunkName: string
/**
* Rendered html file path
*/
htmlFilePath: string
/**
* Rendered html file path relative to dest directory
*/
htmlFilePathRelative: string
}
/**
* Options to create vuepress page
*/
export interface PageOptions {
/**
* If `filePath` is not set, this option will be used as the raw
* markdown content of the page.
*
* If `filePath` is set, this option will be ignored, while the
* content of the file will be used.
*/
content?: string
/**
* Absolute file path of the markdown source file.
*/
filePath?: string
/**
* Default frontmatter of the page, which could be overridden by
* the frontmatter of the markdown content.
*/
frontmatter?: PageFrontmatter
/**
* If this option is set, it will be used as the final route path
* of the page, ignoring the relative path and permalink.
*/
path?: string
}