-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
types.ts
201 lines (177 loc) · 4.79 KB
/
types.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
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
import type MarkdownIt from 'markdown-it'
import type { ComponentPluginOptions } from '@mdit-vue/plugin-component'
import type { FrontmatterPluginOptions } from '@mdit-vue/plugin-frontmatter'
import type { MarkdownItEnv } from '@mdit-vue/types'
import type { FilterPattern } from '@rollup/pluginutils'
import type { preprocessHead } from './core/head'
/** a `<meta />` property in HTML is defined with the following name/values */
export interface MetaProperty {
key?: string
/**
* the "name" property used by Facebook and other providers who
* use the Opengraph standards
*/
property?: string
/**
* used by google to identify the "name" of the name/value pair
*/
itemprop?: string
/**
* used by Twitter to indicate the "name" field in a meta properties
* name/value pairing
*/
name?: string
/**
* The value of the meta property
*/
content?: any
[key: string]: unknown
}
/**
* Frontmatter content is represented as key/value dictionary
*/
export interface Frontmatter {
title?: string
name?: string
description?: string
meta?: MetaProperty[]
[key: string]: unknown
}
export interface Options {
/**
* Explicitly set the Vue version
*
* @default auto detected
*/
vueVersion?: string
/**
* Enable head support, need to install @unhead/vue and register to App in main.js
*
* @default true
*/
headEnabled?: boolean
/**
* The head field in frontmatter used to be used for @unhead/vue
*
* When an empty string is passed, it will use the root properties of the frontmatter
*
* @default ''
*/
headField?: string
/**
* Parse for frontmatter
*
* @default true
*/
frontmatter?: boolean
/**
* Parse for excerpt
*
* If `true`, it will be passed to `frontmatterPreprocess` as `frontmatter.excerpt`, replacing the `excerpt` key in frontmatter, if there's any
*
* @default false
*/
excerpt?: boolean
/**
* Remove custom SFC block
*
* @default ['route', 'i18n']
*/
customSfcBlocks?: string[]
/**
* Options passed to [@mdit-vue/plugin-component](https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-component)
*/
componentOptions?: ComponentPluginOptions
/**
* Options passed to [@mdit-vue/plugin-frontmatter](https://github.com/mdit-vue/mdit-vue/tree/main/packages/plugin-frontmatter)
*/
frontmatterOptions?: FrontmatterPluginOptions
/**
* Custom function to provide defaults to the frontmatter and
* move certain attributes into the "meta" category.
*
* Note: _overriding this will remove built-in functionality setting
* "meta" properties and the built-in "head" support. Do this only
* if you know what you're doing._
*/
frontmatterPreprocess?: (
frontmatter: Frontmatter,
options: ResolvedOptions,
id: string,
defaultHeadProcess: typeof preprocessHead,
) => {
head: Record<string, any>
frontmatter: Frontmatter
}
/**
* Expose frontmatter via expose API
*
* @default true
*/
exposeFrontmatter?: boolean
/**
* Expose excerpt via expose API
*
* @default false
*/
exposeExcerpt?: boolean
/**
* Export frontmatter in component module
*
* @default true
*/
exportFrontmatter?: boolean
/**
* Add `v-pre` to `<code>` tag to escape curly brackets interpolation
*
* @see https://github.com/unplugin/unplugin-vue-markdown/issues/14
* @default true
*/
escapeCodeTagInterpolation?: boolean
/**
* Options passed to Markdown It
*/
markdownItOptions?: MarkdownIt.Options
/**
* Plugins for Markdown It
*/
markdownItUses?: (
| MarkdownIt.PluginSimple
| [MarkdownIt.PluginSimple | MarkdownIt.PluginWithOptions<any>, any]
| any
)[]
/**
* A function providing the Markdown It instance gets the ability to apply custom
* settings/plugins
*/
markdownItSetup?: (MarkdownIt: MarkdownIt) => void | Promise<void>
/**
* Class names for wrapper div
*
* @default 'markdown-body'
*/
wrapperClasses?: string | string[] | undefined | null | ((id: string, code: string) => string | string[] | undefined | null)
/**
* Component name to wrapper with
*
* @default undefined
*/
wrapperComponent?: string | undefined | null | ((id: string, code: string) => string | undefined | null)
/**
* Custom tranformations apply before and after the markdown transformation
*/
transforms?: {
before?: (code: string, id: string) => string
after?: (code: string, id: string) => string
/**
* Return extra code to be injected into the `<script>` tag
*/
extraScripts?: (frontmatter: Record<string, any>, id: string) => string[]
}
include?: FilterPattern
exclude?: FilterPattern
}
export interface ResolvedOptions extends Required<Options> {}
export interface MarkdownEnv extends MarkdownItEnv {
id: string
}