vitepress 0.20.7 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +4 -0
- package/dist/client/app/router.js +2 -2
- package/dist/client/theme-default/components/AlgoliaSearchBox.vue +3 -3
- package/dist/client/theme-default/components/NavBarTitle.vue +3 -0
- package/dist/client/theme-default/composables/sideBar.js +1 -1
- package/dist/node/cli.js +1 -1
- package/dist/node/index.d.ts +162 -14
- package/dist/node/index.js +2 -1
- package/dist/node/{serve-13371594.js → serve-de785cbb.js} +111 -52
- package/dist/vitepress.d.ts +162 -14
- package/package.json +5 -3
- package/types/default-theme.d.ts +146 -0
- package/types/index.d.ts +1 -1
- package/types/shared.d.ts +2 -0
package/client.d.ts
ADDED
|
@@ -9,8 +9,8 @@ const getDefaultRoute = () => ({
|
|
|
9
9
|
component: null,
|
|
10
10
|
// this will be set upon initial page load, which is before
|
|
11
11
|
// the app is mounted, so it's guaranteed to be available in
|
|
12
|
-
// components
|
|
13
|
-
data:
|
|
12
|
+
// components. We just need enough data for 404 pages to render.
|
|
13
|
+
data: { frontmatter: {} }
|
|
14
14
|
});
|
|
15
15
|
export function createRouter(loadPageModule, fallbackComponent) {
|
|
16
16
|
const route = reactive(getDefaultRoute());
|
|
@@ -55,7 +55,7 @@ const { lang } = useData()
|
|
|
55
55
|
// if the user has multiple locales, the search results should be filtered
|
|
56
56
|
// based on the language
|
|
57
57
|
const facetFilters: string[] = props.multilang
|
|
58
|
-
? ['
|
|
58
|
+
? ['lang:' + lang.value]
|
|
59
59
|
: []
|
|
60
60
|
|
|
61
61
|
if (props.options.searchParameters?.facetFilters) {
|
|
@@ -66,10 +66,10 @@ watch(
|
|
|
66
66
|
lang,
|
|
67
67
|
(newLang, oldLang) => {
|
|
68
68
|
const index = facetFilters.findIndex(
|
|
69
|
-
(filter) => filter === '
|
|
69
|
+
(filter) => filter === 'lang:' + oldLang
|
|
70
70
|
)
|
|
71
71
|
if (index > -1) {
|
|
72
|
-
facetFilters.splice(index, 1, '
|
|
72
|
+
facetFilters.splice(index, 1, 'lang:' + newLang)
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
)
|
|
@@ -15,7 +15,7 @@ export function useSideBar() {
|
|
|
15
15
|
if (frontSidebar === false) {
|
|
16
16
|
return [];
|
|
17
17
|
}
|
|
18
|
-
// if it's `
|
|
18
|
+
// if it's `auto`, render headers of the current page
|
|
19
19
|
if (frontSidebar === 'auto') {
|
|
20
20
|
return resolveAutoSidebar(headers, sidebarDepth);
|
|
21
21
|
}
|
package/dist/node/cli.js
CHANGED
package/dist/node/index.d.ts
CHANGED
|
@@ -15,10 +15,162 @@ export declare const createMarkdownRenderer: (srcDir: string, options?: Markdown
|
|
|
15
15
|
|
|
16
16
|
export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
|
|
17
17
|
|
|
18
|
+
export declare namespace DefaultTheme {
|
|
19
|
+
export interface Config {
|
|
20
|
+
logo?: string
|
|
21
|
+
nav?: NavItem[] | false
|
|
22
|
+
sidebar?: SideBarConfig | MultiSideBarConfig
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* GitHub repository following the format <user>/<project>.
|
|
26
|
+
*
|
|
27
|
+
* @example `"vuejs/vue-next"`
|
|
28
|
+
*/
|
|
29
|
+
repo?: string
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
|
33
|
+
* depending on the provided repo.
|
|
34
|
+
*
|
|
35
|
+
* @example `"Contribute!"`
|
|
36
|
+
*/
|
|
37
|
+
repoLabel?: string
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* If your docs are in a different repository from your main project.
|
|
41
|
+
*
|
|
42
|
+
* @example `"vuejs/docs-next"`
|
|
43
|
+
*/
|
|
44
|
+
docsRepo?: string
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If your docs are not at the root of the repo.
|
|
48
|
+
*
|
|
49
|
+
* @example `"docs"`
|
|
50
|
+
*/
|
|
51
|
+
docsDir?: string
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* If your docs are in a different branch. Defaults to `master`.
|
|
55
|
+
*
|
|
56
|
+
* @example `"next"`
|
|
57
|
+
*/
|
|
58
|
+
docsBranch?: string
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Enable links to edit pages at the bottom of the page.
|
|
62
|
+
*/
|
|
63
|
+
editLinks?: boolean
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Custom text for edit link. Defaults to "Edit this page".
|
|
67
|
+
*/
|
|
68
|
+
editLinkText?: string
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Show last updated time at the bottom of the page. Defaults to `false`.
|
|
72
|
+
* If given a string, it will be displayed as a prefix (default value:
|
|
73
|
+
* "Last Updated").
|
|
74
|
+
*/
|
|
75
|
+
lastUpdated?: string | boolean
|
|
76
|
+
|
|
77
|
+
prevLinks?: boolean
|
|
78
|
+
nextLinks?: boolean
|
|
79
|
+
|
|
80
|
+
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
|
81
|
+
|
|
82
|
+
algolia?: AlgoliaSearchOptions
|
|
83
|
+
|
|
84
|
+
carbonAds?: {
|
|
85
|
+
carbon: string
|
|
86
|
+
custom?: string
|
|
87
|
+
placement: string
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// navbar --------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
export type NavItem = NavItemWithLink | NavItemWithChildren
|
|
94
|
+
|
|
95
|
+
export interface NavItemBase {
|
|
96
|
+
text: string
|
|
97
|
+
target?: string
|
|
98
|
+
rel?: string
|
|
99
|
+
ariaLabel?: string
|
|
100
|
+
activeMatch?: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface NavItemWithLink extends NavItemBase {
|
|
104
|
+
link: string
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface NavItemWithChildren extends NavItemBase {
|
|
108
|
+
items: NavItemWithLink[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// sidebar -------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
|
114
|
+
|
|
115
|
+
export interface MultiSideBarConfig {
|
|
116
|
+
[path: string]: SideBarConfig
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type SideBarItem = SideBarLink | SideBarGroup
|
|
120
|
+
|
|
121
|
+
export interface SideBarLink {
|
|
122
|
+
text: string
|
|
123
|
+
link: string
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface SideBarGroup {
|
|
127
|
+
text: string
|
|
128
|
+
link?: string
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
collapsable?: boolean
|
|
134
|
+
|
|
135
|
+
children: SideBarItem[]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// algolia ------------------------------------------------------------------
|
|
139
|
+
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
|
140
|
+
export interface AlgoliaSearchOptions {
|
|
141
|
+
appId?: string
|
|
142
|
+
apiKey: string
|
|
143
|
+
indexName: string
|
|
144
|
+
placeholder?: string
|
|
145
|
+
searchParameters?: any
|
|
146
|
+
disableUserPersonalization?: boolean
|
|
147
|
+
initialQuery?: string
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// locales -------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
export interface LocaleConfig {
|
|
153
|
+
/**
|
|
154
|
+
* Text for the language dropdown.
|
|
155
|
+
*/
|
|
156
|
+
selectText?: string
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Label for this locale in the language dropdown.
|
|
160
|
+
*/
|
|
161
|
+
label?: string
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
18
165
|
/**
|
|
19
166
|
* Type config helper
|
|
20
167
|
*/
|
|
21
|
-
export declare function defineConfig(config:
|
|
168
|
+
export declare function defineConfig(config: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Type config helper for custom theme config
|
|
172
|
+
*/
|
|
173
|
+
export declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
|
|
22
174
|
|
|
23
175
|
export declare type HeadConfig =
|
|
24
176
|
| [string, Record<string, string>]
|
|
@@ -60,15 +212,13 @@ export declare interface MarkdownParsedData {
|
|
|
60
212
|
headers?: Header[];
|
|
61
213
|
}
|
|
62
214
|
|
|
63
|
-
export declare interface MarkdownRenderer {
|
|
215
|
+
export declare interface MarkdownRenderer extends MarkdownIt {
|
|
216
|
+
__path: string;
|
|
217
|
+
__relativePath: string;
|
|
64
218
|
__data: MarkdownParsedData;
|
|
65
|
-
render: (src: string, env?: any) => {
|
|
66
|
-
html: string;
|
|
67
|
-
data: any;
|
|
68
|
-
};
|
|
69
219
|
}
|
|
70
220
|
|
|
71
|
-
export declare type RawConfigExports = UserConfig | Promise<UserConfig
|
|
221
|
+
export declare type RawConfigExports<ThemeConfig = any> = UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>> | (() => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>);
|
|
72
222
|
|
|
73
223
|
export declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
|
|
74
224
|
|
|
@@ -83,7 +233,7 @@ export declare interface ServeOptions {
|
|
|
83
233
|
port?: number;
|
|
84
234
|
}
|
|
85
235
|
|
|
86
|
-
export declare interface SiteConfig<ThemeConfig = any> {
|
|
236
|
+
export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa'> {
|
|
87
237
|
root: string;
|
|
88
238
|
srcDir: string;
|
|
89
239
|
site: SiteData<ThemeConfig>;
|
|
@@ -93,10 +243,6 @@ export declare interface SiteConfig<ThemeConfig = any> {
|
|
|
93
243
|
tempDir: string;
|
|
94
244
|
alias: AliasOptions;
|
|
95
245
|
pages: string[];
|
|
96
|
-
markdown: MarkdownOptions | undefined;
|
|
97
|
-
vue: Options | undefined;
|
|
98
|
-
vite: UserConfig_2 | undefined;
|
|
99
|
-
mpa: boolean;
|
|
100
246
|
}
|
|
101
247
|
|
|
102
248
|
export declare interface SiteData<ThemeConfig = any> {
|
|
@@ -134,7 +280,7 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
134
280
|
}
|
|
135
281
|
|
|
136
282
|
export declare interface UserConfig<ThemeConfig = any> {
|
|
137
|
-
extends?: RawConfigExports
|
|
283
|
+
extends?: RawConfigExports<ThemeConfig>;
|
|
138
284
|
lang?: string;
|
|
139
285
|
base?: string;
|
|
140
286
|
title?: string;
|
|
@@ -144,7 +290,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
144
290
|
locales?: Record<string, LocaleConfig>;
|
|
145
291
|
markdown?: MarkdownOptions;
|
|
146
292
|
/**
|
|
147
|
-
*
|
|
293
|
+
* Options to pass on to `@vitejs/plugin-vue`
|
|
148
294
|
*/
|
|
149
295
|
vue?: Options;
|
|
150
296
|
/**
|
|
@@ -153,6 +299,8 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
153
299
|
vite?: UserConfig_2;
|
|
154
300
|
srcDir?: string;
|
|
155
301
|
srcExclude?: string[];
|
|
302
|
+
outDir?: string;
|
|
303
|
+
shouldPreload?: (link: string, page: string) => boolean;
|
|
156
304
|
/**
|
|
157
305
|
* Enable MPA / zero-JS mode
|
|
158
306
|
* @experimental
|
package/dist/node/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var serve = require('./serve-
|
|
5
|
+
var serve = require('./serve-de785cbb.js');
|
|
6
6
|
require('vite');
|
|
7
7
|
require('readline');
|
|
8
8
|
require('assert');
|
|
@@ -29,6 +29,7 @@ exports.build = serve.build;
|
|
|
29
29
|
exports.createMarkdownRenderer = serve.createMarkdownRenderer;
|
|
30
30
|
exports.createServer = serve.createServer;
|
|
31
31
|
exports.defineConfig = serve.defineConfig;
|
|
32
|
+
exports.defineConfigWithTheme = serve.defineConfigWithTheme;
|
|
32
33
|
exports.resolveConfig = serve.resolveConfig;
|
|
33
34
|
exports.resolveSiteData = serve.resolveSiteData;
|
|
34
35
|
exports.resolveSiteDataByRoute = serve.resolveSiteDataByRoute;
|
|
@@ -13349,10 +13349,14 @@ const resolve = (root, file) => vite.normalizePath(path__default["default"].reso
|
|
|
13349
13349
|
function defineConfig(config) {
|
|
13350
13350
|
return config;
|
|
13351
13351
|
}
|
|
13352
|
+
function defineConfigWithTheme(config) {
|
|
13353
|
+
return config;
|
|
13354
|
+
}
|
|
13352
13355
|
async function resolveConfig(root = process.cwd(), command = "serve", mode = "development") {
|
|
13353
13356
|
const [userConfig, configPath] = await resolveUserConfig(root, command, mode);
|
|
13354
13357
|
const site = await resolveSiteData(root, userConfig);
|
|
13355
13358
|
const srcDir = path__default["default"].resolve(root, userConfig.srcDir || ".");
|
|
13359
|
+
const outDir = userConfig.outDir ? path__default["default"].resolve(root, userConfig.outDir) : resolve(root, "dist");
|
|
13356
13360
|
const userThemeDir = resolve(root, "theme");
|
|
13357
13361
|
const themeDir = await lib$1.pathExists(userThemeDir) ? userThemeDir : DEFAULT_THEME_PATH;
|
|
13358
13362
|
const pages = (await globby(["**.md"], {
|
|
@@ -13366,17 +13370,18 @@ async function resolveConfig(root = process.cwd(), command = "serve", mode = "de
|
|
|
13366
13370
|
themeDir,
|
|
13367
13371
|
pages,
|
|
13368
13372
|
configPath,
|
|
13369
|
-
outDir
|
|
13370
|
-
tempDir:
|
|
13373
|
+
outDir,
|
|
13374
|
+
tempDir: resolve(root, ".temp"),
|
|
13371
13375
|
markdown: userConfig.markdown,
|
|
13372
13376
|
alias: resolveAliases(themeDir),
|
|
13373
13377
|
vue: userConfig.vue,
|
|
13374
13378
|
vite: userConfig.vite,
|
|
13379
|
+
shouldPreload: userConfig.shouldPreload,
|
|
13375
13380
|
mpa: !!userConfig.mpa
|
|
13376
13381
|
};
|
|
13377
13382
|
return config;
|
|
13378
13383
|
}
|
|
13379
|
-
const supportedConfigExtensions = ["js", "ts", "
|
|
13384
|
+
const supportedConfigExtensions = ["js", "ts", "mjs", "mts"];
|
|
13380
13385
|
async function resolveUserConfig(root, command, mode) {
|
|
13381
13386
|
var _a;
|
|
13382
13387
|
let configPath;
|
|
@@ -34186,10 +34191,11 @@ var require$$0$4 = {
|
|
|
34186
34191
|
};
|
|
34187
34192
|
|
|
34188
34193
|
const parseEmojis = (str) => {
|
|
34189
|
-
return
|
|
34194
|
+
return str.replace(/:(.+?):/g, (placeholder, key) => require$$0$4[key] || placeholder);
|
|
34190
34195
|
};
|
|
34191
|
-
const unescapeHtml = (html) =>
|
|
34192
|
-
const removeMarkdownTokens = (str) =>
|
|
34196
|
+
const unescapeHtml = (html) => html.replace(/"/g, '"').replace(/'/g, "'").replace(/:/g, ":").replace(/</g, "<").replace(/>/g, ">");
|
|
34197
|
+
const removeMarkdownTokens = (str) => str.replace(/(\[(.[^\]]+)\]\((.[^)]+)\))/g, "$2").replace(/(`|\*{1,3}|_)(.*?[^\\])\1/g, "$2").replace(/(\\)(\*|_|`|\!|<|\$)/g, "$2");
|
|
34198
|
+
const remvoeCustomAnchor = (str) => str.replace(/\{#([a-z0-9\-_]+?)\}\s*$/, "");
|
|
34193
34199
|
const trim = (str) => str.trim();
|
|
34194
34200
|
const removeNonCodeWrappedHTML = (str) => {
|
|
34195
34201
|
return String(str).replace(/(^|[^><`\\])<.*>([^><`]|$)/g, "$1$2");
|
|
@@ -34203,7 +34209,7 @@ const compose = (...processors) => {
|
|
|
34203
34209
|
return (str) => next(prev(str));
|
|
34204
34210
|
});
|
|
34205
34211
|
};
|
|
34206
|
-
const parseHeader = compose(unescapeHtml, parseEmojis, removeMarkdownTokens, trim);
|
|
34212
|
+
const parseHeader = compose(unescapeHtml, parseEmojis, remvoeCustomAnchor, removeMarkdownTokens, trim);
|
|
34207
34213
|
const deeplyParseHeader = compose(removeNonCodeWrappedHTML, parseHeader);
|
|
34208
34214
|
|
|
34209
34215
|
/*!
|
|
@@ -34900,7 +34906,7 @@ var markdownItContainer = function container_plugin(md, name, options) {
|
|
|
34900
34906
|
};
|
|
34901
34907
|
|
|
34902
34908
|
const containerPlugin = (md) => {
|
|
34903
|
-
md.use(...createContainer("tip", "TIP")).use(...createContainer("info", "INFO")).use(...createContainer("warning", "WARNING")).use(...createContainer("danger", "WARNING")).use(markdownItContainer, "v-pre", {
|
|
34909
|
+
md.use(...createContainer("tip", "TIP")).use(...createContainer("info", "INFO")).use(...createContainer("warning", "WARNING")).use(...createContainer("danger", "WARNING")).use(...createContainer("details", "Details")).use(markdownItContainer, "v-pre", {
|
|
34904
34910
|
render: (tokens, idx) => tokens[idx].nesting === 1 ? `<div v-pre>
|
|
34905
34911
|
` : `</div>
|
|
34906
34912
|
`
|
|
@@ -34915,10 +34921,15 @@ function createContainer(klass, defaultTitle) {
|
|
|
34915
34921
|
const token = tokens[idx];
|
|
34916
34922
|
const info = token.info.trim().slice(klass.length).trim();
|
|
34917
34923
|
if (token.nesting === 1) {
|
|
34924
|
+
if (klass === "details") {
|
|
34925
|
+
return `<details class="${klass} custom-block">${info ? `<summary>${info}</summary>` : ""}
|
|
34926
|
+
`;
|
|
34927
|
+
}
|
|
34918
34928
|
return `<div class="${klass} custom-block"><p class="custom-block-title">${info || defaultTitle}</p>
|
|
34919
34929
|
`;
|
|
34920
34930
|
} else {
|
|
34921
|
-
return `</
|
|
34931
|
+
return klass === "details" ? `</details>
|
|
34932
|
+
` : `</div>
|
|
34922
34933
|
`;
|
|
34923
34934
|
}
|
|
34924
34935
|
}
|
|
@@ -35074,6 +35085,9 @@ const linkPlugin = (md, externalAttrs) => {
|
|
|
35074
35085
|
Object.entries(externalAttrs).forEach(([key, val]) => {
|
|
35075
35086
|
token.attrSet(key, val);
|
|
35076
35087
|
});
|
|
35088
|
+
if (url.replace(EXTERNAL_URL_RE, "").startsWith("//localhost:")) {
|
|
35089
|
+
pushLink(url);
|
|
35090
|
+
}
|
|
35077
35091
|
} else if (!url.startsWith("#") && !url.startsWith("mailto:")) {
|
|
35078
35092
|
normalizeHref(hrefAttr);
|
|
35079
35093
|
}
|
|
@@ -35101,14 +35115,17 @@ const linkPlugin = (md, externalAttrs) => {
|
|
|
35101
35115
|
if (!url.startsWith("/") && !/^\.\//.test(url)) {
|
|
35102
35116
|
url = "./" + url;
|
|
35103
35117
|
}
|
|
35118
|
+
pushLink(url.replace(/\.html$/, ""));
|
|
35119
|
+
hrefAttr[1] = decodeURI(url);
|
|
35120
|
+
}
|
|
35121
|
+
function pushLink(link) {
|
|
35104
35122
|
const data = md.__data;
|
|
35105
35123
|
const links = data.links || (data.links = []);
|
|
35106
|
-
links.push(
|
|
35107
|
-
hrefAttr[1] = decodeURI(url);
|
|
35124
|
+
links.push(link);
|
|
35108
35125
|
}
|
|
35109
35126
|
};
|
|
35110
35127
|
|
|
35111
|
-
const
|
|
35128
|
+
const headingPlugin = (md, include = ["h2", "h3"]) => {
|
|
35112
35129
|
md.renderer.rules.heading_open = (tokens, i, options, env, self) => {
|
|
35113
35130
|
const token = tokens[i];
|
|
35114
35131
|
if (include.includes(token.tag)) {
|
|
@@ -36277,7 +36294,7 @@ const createMarkdownRenderer = (srcDir, options = {}) => {
|
|
|
36277
36294
|
linkify: true,
|
|
36278
36295
|
highlight
|
|
36279
36296
|
}, options));
|
|
36280
|
-
md.use(componentPlugin).use(highlightLinePlugin).use(preWrapperPlugin).use(snippetPlugin, srcDir).use(hoistPlugin).use(containerPlugin).use(
|
|
36297
|
+
md.use(componentPlugin).use(highlightLinePlugin).use(preWrapperPlugin).use(snippetPlugin, srcDir).use(hoistPlugin).use(containerPlugin).use(headingPlugin).use(linkPlugin, __spreadValues$2({
|
|
36281
36298
|
target: "_blank",
|
|
36282
36299
|
rel: "noopener noreferrer"
|
|
36283
36300
|
}, options.externalLinks)).use(markdownItAttrs, options.attrs).use(b, __spreadValues$2({
|
|
@@ -36294,16 +36311,6 @@ const createMarkdownRenderer = (srcDir, options = {}) => {
|
|
|
36294
36311
|
if (options.lineNumbers) {
|
|
36295
36312
|
md.use(lineNumberPlugin);
|
|
36296
36313
|
}
|
|
36297
|
-
const render = md.render;
|
|
36298
|
-
const wrappedRender = (src) => {
|
|
36299
|
-
md.__data = {};
|
|
36300
|
-
const html = render.call(md, src);
|
|
36301
|
-
return {
|
|
36302
|
-
html,
|
|
36303
|
-
data: md.__data
|
|
36304
|
-
};
|
|
36305
|
-
};
|
|
36306
|
-
md.render = wrappedRender;
|
|
36307
36314
|
return md;
|
|
36308
36315
|
};
|
|
36309
36316
|
|
|
@@ -36335,7 +36342,11 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36335
36342
|
return content2;
|
|
36336
36343
|
});
|
|
36337
36344
|
const { content, data: frontmatter } = grayMatter(src);
|
|
36338
|
-
|
|
36345
|
+
md.__path = file;
|
|
36346
|
+
md.__relativePath = relativePath;
|
|
36347
|
+
md.__data = {};
|
|
36348
|
+
let html = md.render(content);
|
|
36349
|
+
const data = md.__data;
|
|
36339
36350
|
if (isBuild) {
|
|
36340
36351
|
html = html.replace(/\bimport\.meta/g, "import.<wbr/>meta").replace(/\bprocess\.env/g, "process.<wbr/>env");
|
|
36341
36352
|
if (userDefineRegex) {
|
|
@@ -36343,17 +36354,24 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36343
36354
|
}
|
|
36344
36355
|
}
|
|
36345
36356
|
const deadLinks = [];
|
|
36357
|
+
const recordDeadLink = (url) => {
|
|
36358
|
+
console.warn(source.yellow(`
|
|
36359
|
+
(!) Found dead link ${source.cyan(url)} in file ${source.white.dim(file)}`));
|
|
36360
|
+
deadLinks.push(url);
|
|
36361
|
+
};
|
|
36346
36362
|
if (data.links) {
|
|
36347
36363
|
const dir2 = path__default["default"].dirname(file);
|
|
36348
36364
|
for (let url of data.links) {
|
|
36365
|
+
if (url.replace(EXTERNAL_URL_RE, "").startsWith("//localhost:")) {
|
|
36366
|
+
recordDeadLink(url);
|
|
36367
|
+
continue;
|
|
36368
|
+
}
|
|
36349
36369
|
url = url.replace(/[?#].*$/, "").replace(/\.(html|md)$/, "");
|
|
36350
36370
|
if (url.endsWith("/"))
|
|
36351
36371
|
url += `index`;
|
|
36352
|
-
const resolved = slash(url.startsWith("/") ? url.slice(1) : path__default["default"].relative(srcDir, path__default["default"].resolve(dir2, url)));
|
|
36372
|
+
const resolved = decodeURIComponent(slash(url.startsWith("/") ? url.slice(1) : path__default["default"].relative(srcDir, path__default["default"].resolve(dir2, url))));
|
|
36353
36373
|
if (!pages.includes(resolved) && !fs__default["default"].existsSync(path__default["default"].resolve(dir2, publicDir, `${resolved}.html`))) {
|
|
36354
|
-
|
|
36355
|
-
(!) Found dead link ${source.cyan(url)} in file ${source.white.dim(file)}`));
|
|
36356
|
-
deadLinks.push(url);
|
|
36374
|
+
recordDeadLink(url);
|
|
36357
36375
|
}
|
|
36358
36376
|
}
|
|
36359
36377
|
}
|
|
@@ -36361,7 +36379,7 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36361
36379
|
title: inferTitle(frontmatter, content),
|
|
36362
36380
|
description: inferDescription(frontmatter),
|
|
36363
36381
|
frontmatter,
|
|
36364
|
-
headers: data.headers,
|
|
36382
|
+
headers: data.headers || [],
|
|
36365
36383
|
relativePath,
|
|
36366
36384
|
lastUpdated: Math.round(fs__default["default"].statSync(file).mtimeMs)
|
|
36367
36385
|
};
|
|
@@ -36464,9 +36482,11 @@ const staticDataPlugin = {
|
|
|
36464
36482
|
({ pattern, loader } = existing);
|
|
36465
36483
|
} else {
|
|
36466
36484
|
const loaderModule = (_a = await vite.loadConfigFromFile({}, id)) == null ? void 0 : _a.config;
|
|
36467
|
-
pattern = loaderModule.watch;
|
|
36468
|
-
if (pattern
|
|
36469
|
-
pattern = pattern.
|
|
36485
|
+
pattern = typeof loaderModule.watch === "string" ? [loaderModule.watch] : loaderModule.watch;
|
|
36486
|
+
if (pattern) {
|
|
36487
|
+
pattern = pattern.map((p) => {
|
|
36488
|
+
return p.startsWith("./") ? p.slice(2) : p;
|
|
36489
|
+
});
|
|
36470
36490
|
}
|
|
36471
36491
|
loader = loaderModule.load;
|
|
36472
36492
|
}
|
|
@@ -36485,7 +36505,7 @@ const staticDataPlugin = {
|
|
|
36485
36505
|
const { base, pattern } = idToLoaderModulesMap[id];
|
|
36486
36506
|
server._globImporters[id] = {
|
|
36487
36507
|
module: server.moduleGraph.getModuleById(id),
|
|
36488
|
-
importGlobs:
|
|
36508
|
+
importGlobs: pattern == null ? void 0 : pattern.map((pattern2) => ({ base, pattern: pattern2 }))
|
|
36489
36509
|
};
|
|
36490
36510
|
}
|
|
36491
36511
|
return null;
|
|
@@ -40039,13 +40059,25 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40039
40059
|
const pageClientJsFileName = `assets/${pageName}.${pageHash}.lean.js`;
|
|
40040
40060
|
const { __pageData } = require(path__default["default"].join(config.tempDir, pageServerJsFileName));
|
|
40041
40061
|
const pageData = JSON.parse(__pageData);
|
|
40042
|
-
|
|
40043
|
-
...
|
|
40044
|
-
|
|
40045
|
-
|
|
40046
|
-
|
|
40062
|
+
let preloadLinks = config.mpa ? appChunk ? [appChunk.fileName] : [] : result && appChunk ? [
|
|
40063
|
+
...new Set([
|
|
40064
|
+
...resolvePageImports(config, page, result, appChunk),
|
|
40065
|
+
pageClientJsFileName,
|
|
40066
|
+
appChunk.fileName
|
|
40067
|
+
])
|
|
40068
|
+
] : [];
|
|
40069
|
+
let prefetchLinks = [];
|
|
40070
|
+
const { shouldPreload } = config;
|
|
40071
|
+
if (shouldPreload) {
|
|
40072
|
+
prefetchLinks = preloadLinks.filter((link) => !shouldPreload(link, page));
|
|
40073
|
+
preloadLinks = preloadLinks.filter((link) => shouldPreload(link, page));
|
|
40074
|
+
}
|
|
40075
|
+
const preloadLinksString = preloadLinks.map((file) => {
|
|
40047
40076
|
return `<link rel="modulepreload" href="${siteData.base}${file}">`;
|
|
40048
40077
|
}).join("\n ");
|
|
40078
|
+
const prefetchLinkString = prefetchLinks.map((file) => {
|
|
40079
|
+
return `<link rel="prefetch" href="${siteData.base}${file}">`;
|
|
40080
|
+
}).join("\n ");
|
|
40049
40081
|
const stylesheetLink = cssChunk ? `<link rel="stylesheet" href="${siteData.base}${cssChunk.fileName}">` : "";
|
|
40050
40082
|
const title = pageData.title && pageData.title !== "Home" ? `${pageData.title} | ${siteData.title}` : siteData.title;
|
|
40051
40083
|
const head = addSocialTags(title, ...siteData.head, ...filterOutHeadDescription(pageData.frontmatter.head));
|
|
@@ -40070,8 +40102,9 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40070
40102
|
<title>${title}</title>
|
|
40071
40103
|
<meta name="description" content="${pageData.description || siteData.description}">
|
|
40072
40104
|
${stylesheetLink}
|
|
40073
|
-
${
|
|
40074
|
-
${
|
|
40105
|
+
${preloadLinksString}
|
|
40106
|
+
${prefetchLinkString}
|
|
40107
|
+
${await renderHead(head)}
|
|
40075
40108
|
</head>
|
|
40076
40109
|
<body>
|
|
40077
40110
|
<div id="app">${content}</div>
|
|
@@ -40084,25 +40117,30 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40084
40117
|
await lib$1.ensureDir(path__default["default"].dirname(htmlFileName));
|
|
40085
40118
|
await lib$1.writeFile(htmlFileName, html);
|
|
40086
40119
|
}
|
|
40087
|
-
function resolvePageImports(config, page, result,
|
|
40120
|
+
function resolvePageImports(config, page, result, appChunk) {
|
|
40088
40121
|
const srcPath = vite.normalizePath(lib$1.realpathSync(path__default["default"].resolve(config.srcDir, page)));
|
|
40089
40122
|
const pageChunk = result.output.find((chunk) => chunk.type === "chunk" && chunk.facadeModuleId === srcPath);
|
|
40090
|
-
return
|
|
40091
|
-
...
|
|
40092
|
-
...
|
|
40123
|
+
return [
|
|
40124
|
+
...appChunk.imports,
|
|
40125
|
+
...appChunk.dynamicImports,
|
|
40093
40126
|
...pageChunk.imports,
|
|
40094
40127
|
...pageChunk.dynamicImports
|
|
40095
|
-
]
|
|
40128
|
+
];
|
|
40096
40129
|
}
|
|
40097
40130
|
function renderHead(head) {
|
|
40098
|
-
return head.map(([tag, attrs = {}, innerHTML = ""]) => {
|
|
40131
|
+
return Promise.all(head.map(async ([tag, attrs = {}, innerHTML = ""]) => {
|
|
40099
40132
|
const openTag = `<${tag}${renderAttrs(attrs)}>`;
|
|
40100
40133
|
if (tag !== "link" && tag !== "meta") {
|
|
40134
|
+
if (tag === "script") {
|
|
40135
|
+
innerHTML = (await vite.transformWithEsbuild(innerHTML, "inline-script.js", {
|
|
40136
|
+
minify: true
|
|
40137
|
+
})).code.trim();
|
|
40138
|
+
}
|
|
40101
40139
|
return `${openTag}${innerHTML}</${tag}>`;
|
|
40102
40140
|
} else {
|
|
40103
40141
|
return openTag;
|
|
40104
40142
|
}
|
|
40105
|
-
}).join("\n
|
|
40143
|
+
})).then((tags) => tags.join("\n "));
|
|
40106
40144
|
}
|
|
40107
40145
|
function renderAttrs(attrs) {
|
|
40108
40146
|
return Object.keys(attrs).map((key) => {
|
|
@@ -65074,9 +65112,20 @@ class Polka extends Router {
|
|
|
65074
65112
|
|
|
65075
65113
|
var polka = opts => new Polka(opts);
|
|
65076
65114
|
|
|
65115
|
+
function trimChar(str, char) {
|
|
65116
|
+
while (str.charAt(0) === char) {
|
|
65117
|
+
str = str.substring(1);
|
|
65118
|
+
}
|
|
65119
|
+
while (str.charAt(str.length - 1) === char) {
|
|
65120
|
+
str = str.substring(0, str.length - 1);
|
|
65121
|
+
}
|
|
65122
|
+
return str;
|
|
65123
|
+
}
|
|
65077
65124
|
async function serve(options = {}) {
|
|
65125
|
+
var _a, _b;
|
|
65078
65126
|
const port = options.port !== void 0 ? options.port : 5e3;
|
|
65079
65127
|
const site = await resolveConfig(options.root, "serve", "production");
|
|
65128
|
+
const base = trimChar((_b = (_a = site == null ? void 0 : site.site) == null ? void 0 : _a.base) != null ? _b : "", "/");
|
|
65080
65129
|
const compress = compression$1();
|
|
65081
65130
|
const serve2 = sirv(site.outDir, {
|
|
65082
65131
|
etag: true,
|
|
@@ -65089,18 +65138,28 @@ async function serve(options = {}) {
|
|
|
65089
65138
|
}
|
|
65090
65139
|
}
|
|
65091
65140
|
});
|
|
65092
|
-
|
|
65093
|
-
|
|
65094
|
-
|
|
65095
|
-
|
|
65141
|
+
if (base) {
|
|
65142
|
+
polka().use(base, compress, serve2).listen(port, (err) => {
|
|
65143
|
+
if (err)
|
|
65144
|
+
throw err;
|
|
65145
|
+
console.log(`Built site served at http://localhost:${port}/${base}/
|
|
65096
65146
|
`);
|
|
65097
|
-
|
|
65147
|
+
});
|
|
65148
|
+
} else {
|
|
65149
|
+
polka().use(compress, serve2).listen(port, (err) => {
|
|
65150
|
+
if (err)
|
|
65151
|
+
throw err;
|
|
65152
|
+
console.log(`Built site served at http://localhost:${port}/
|
|
65153
|
+
`);
|
|
65154
|
+
});
|
|
65155
|
+
}
|
|
65098
65156
|
}
|
|
65099
65157
|
|
|
65100
65158
|
exports.build = build;
|
|
65101
65159
|
exports.createMarkdownRenderer = createMarkdownRenderer;
|
|
65102
65160
|
exports.createServer = createServer;
|
|
65103
65161
|
exports.defineConfig = defineConfig;
|
|
65162
|
+
exports.defineConfigWithTheme = defineConfigWithTheme;
|
|
65104
65163
|
exports.resolveConfig = resolveConfig;
|
|
65105
65164
|
exports.resolveSiteData = resolveSiteData;
|
|
65106
65165
|
exports.resolveSiteDataByRoute = resolveSiteDataByRoute;
|
package/dist/vitepress.d.ts
CHANGED
|
@@ -15,10 +15,162 @@ export declare const createMarkdownRenderer: (srcDir: string, options?: Markdown
|
|
|
15
15
|
|
|
16
16
|
export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
|
|
17
17
|
|
|
18
|
+
export declare namespace DefaultTheme {
|
|
19
|
+
export interface Config {
|
|
20
|
+
logo?: string
|
|
21
|
+
nav?: NavItem[] | false
|
|
22
|
+
sidebar?: SideBarConfig | MultiSideBarConfig
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* GitHub repository following the format <user>/<project>.
|
|
26
|
+
*
|
|
27
|
+
* @example `"vuejs/vue-next"`
|
|
28
|
+
*/
|
|
29
|
+
repo?: string
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
|
33
|
+
* depending on the provided repo.
|
|
34
|
+
*
|
|
35
|
+
* @example `"Contribute!"`
|
|
36
|
+
*/
|
|
37
|
+
repoLabel?: string
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* If your docs are in a different repository from your main project.
|
|
41
|
+
*
|
|
42
|
+
* @example `"vuejs/docs-next"`
|
|
43
|
+
*/
|
|
44
|
+
docsRepo?: string
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* If your docs are not at the root of the repo.
|
|
48
|
+
*
|
|
49
|
+
* @example `"docs"`
|
|
50
|
+
*/
|
|
51
|
+
docsDir?: string
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* If your docs are in a different branch. Defaults to `master`.
|
|
55
|
+
*
|
|
56
|
+
* @example `"next"`
|
|
57
|
+
*/
|
|
58
|
+
docsBranch?: string
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Enable links to edit pages at the bottom of the page.
|
|
62
|
+
*/
|
|
63
|
+
editLinks?: boolean
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Custom text for edit link. Defaults to "Edit this page".
|
|
67
|
+
*/
|
|
68
|
+
editLinkText?: string
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Show last updated time at the bottom of the page. Defaults to `false`.
|
|
72
|
+
* If given a string, it will be displayed as a prefix (default value:
|
|
73
|
+
* "Last Updated").
|
|
74
|
+
*/
|
|
75
|
+
lastUpdated?: string | boolean
|
|
76
|
+
|
|
77
|
+
prevLinks?: boolean
|
|
78
|
+
nextLinks?: boolean
|
|
79
|
+
|
|
80
|
+
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
|
81
|
+
|
|
82
|
+
algolia?: AlgoliaSearchOptions
|
|
83
|
+
|
|
84
|
+
carbonAds?: {
|
|
85
|
+
carbon: string
|
|
86
|
+
custom?: string
|
|
87
|
+
placement: string
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// navbar --------------------------------------------------------------------
|
|
92
|
+
|
|
93
|
+
export type NavItem = NavItemWithLink | NavItemWithChildren
|
|
94
|
+
|
|
95
|
+
export interface NavItemBase {
|
|
96
|
+
text: string
|
|
97
|
+
target?: string
|
|
98
|
+
rel?: string
|
|
99
|
+
ariaLabel?: string
|
|
100
|
+
activeMatch?: string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface NavItemWithLink extends NavItemBase {
|
|
104
|
+
link: string
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface NavItemWithChildren extends NavItemBase {
|
|
108
|
+
items: NavItemWithLink[]
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// sidebar -------------------------------------------------------------------
|
|
112
|
+
|
|
113
|
+
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
|
114
|
+
|
|
115
|
+
export interface MultiSideBarConfig {
|
|
116
|
+
[path: string]: SideBarConfig
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export type SideBarItem = SideBarLink | SideBarGroup
|
|
120
|
+
|
|
121
|
+
export interface SideBarLink {
|
|
122
|
+
text: string
|
|
123
|
+
link: string
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface SideBarGroup {
|
|
127
|
+
text: string
|
|
128
|
+
link?: string
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* @default false
|
|
132
|
+
*/
|
|
133
|
+
collapsable?: boolean
|
|
134
|
+
|
|
135
|
+
children: SideBarItem[]
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// algolia ------------------------------------------------------------------
|
|
139
|
+
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
|
140
|
+
export interface AlgoliaSearchOptions {
|
|
141
|
+
appId?: string
|
|
142
|
+
apiKey: string
|
|
143
|
+
indexName: string
|
|
144
|
+
placeholder?: string
|
|
145
|
+
searchParameters?: any
|
|
146
|
+
disableUserPersonalization?: boolean
|
|
147
|
+
initialQuery?: string
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// locales -------------------------------------------------------------------
|
|
151
|
+
|
|
152
|
+
export interface LocaleConfig {
|
|
153
|
+
/**
|
|
154
|
+
* Text for the language dropdown.
|
|
155
|
+
*/
|
|
156
|
+
selectText?: string
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Label for this locale in the language dropdown.
|
|
160
|
+
*/
|
|
161
|
+
label?: string
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
18
165
|
/**
|
|
19
166
|
* Type config helper
|
|
20
167
|
*/
|
|
21
|
-
export declare function defineConfig(config:
|
|
168
|
+
export declare function defineConfig(config: UserConfig<DefaultTheme.Config>): UserConfig<DefaultTheme.Config>;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Type config helper for custom theme config
|
|
172
|
+
*/
|
|
173
|
+
export declare function defineConfigWithTheme<ThemeConfig>(config: UserConfig<ThemeConfig>): UserConfig<ThemeConfig>;
|
|
22
174
|
|
|
23
175
|
export declare type HeadConfig =
|
|
24
176
|
| [string, Record<string, string>]
|
|
@@ -60,15 +212,13 @@ export declare interface MarkdownParsedData {
|
|
|
60
212
|
headers?: Header[];
|
|
61
213
|
}
|
|
62
214
|
|
|
63
|
-
export declare interface MarkdownRenderer {
|
|
215
|
+
export declare interface MarkdownRenderer extends MarkdownIt {
|
|
216
|
+
__path: string;
|
|
217
|
+
__relativePath: string;
|
|
64
218
|
__data: MarkdownParsedData;
|
|
65
|
-
render: (src: string, env?: any) => {
|
|
66
|
-
html: string;
|
|
67
|
-
data: any;
|
|
68
|
-
};
|
|
69
219
|
}
|
|
70
220
|
|
|
71
|
-
export declare type RawConfigExports = UserConfig | Promise<UserConfig
|
|
221
|
+
export declare type RawConfigExports<ThemeConfig = any> = UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>> | (() => UserConfig<ThemeConfig> | Promise<UserConfig<ThemeConfig>>);
|
|
72
222
|
|
|
73
223
|
export declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
|
|
74
224
|
|
|
@@ -83,7 +233,7 @@ export declare interface ServeOptions {
|
|
|
83
233
|
port?: number;
|
|
84
234
|
}
|
|
85
235
|
|
|
86
|
-
export declare interface SiteConfig<ThemeConfig = any> {
|
|
236
|
+
export declare interface SiteConfig<ThemeConfig = any> extends Pick<UserConfig, 'markdown' | 'vue' | 'vite' | 'shouldPreload' | 'mpa'> {
|
|
87
237
|
root: string;
|
|
88
238
|
srcDir: string;
|
|
89
239
|
site: SiteData<ThemeConfig>;
|
|
@@ -93,10 +243,6 @@ export declare interface SiteConfig<ThemeConfig = any> {
|
|
|
93
243
|
tempDir: string;
|
|
94
244
|
alias: AliasOptions;
|
|
95
245
|
pages: string[];
|
|
96
|
-
markdown: MarkdownOptions | undefined;
|
|
97
|
-
vue: Options | undefined;
|
|
98
|
-
vite: UserConfig_2 | undefined;
|
|
99
|
-
mpa: boolean;
|
|
100
246
|
}
|
|
101
247
|
|
|
102
248
|
export declare interface SiteData<ThemeConfig = any> {
|
|
@@ -134,7 +280,7 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
134
280
|
}
|
|
135
281
|
|
|
136
282
|
export declare interface UserConfig<ThemeConfig = any> {
|
|
137
|
-
extends?: RawConfigExports
|
|
283
|
+
extends?: RawConfigExports<ThemeConfig>;
|
|
138
284
|
lang?: string;
|
|
139
285
|
base?: string;
|
|
140
286
|
title?: string;
|
|
@@ -144,7 +290,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
144
290
|
locales?: Record<string, LocaleConfig>;
|
|
145
291
|
markdown?: MarkdownOptions;
|
|
146
292
|
/**
|
|
147
|
-
*
|
|
293
|
+
* Options to pass on to `@vitejs/plugin-vue`
|
|
148
294
|
*/
|
|
149
295
|
vue?: Options;
|
|
150
296
|
/**
|
|
@@ -153,6 +299,8 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
153
299
|
vite?: UserConfig_2;
|
|
154
300
|
srcDir?: string;
|
|
155
301
|
srcExclude?: string[];
|
|
302
|
+
outDir?: string;
|
|
303
|
+
shouldPreload?: (link: string, page: string) => boolean;
|
|
156
304
|
/**
|
|
157
305
|
* Enable MPA / zero-JS mode
|
|
158
306
|
* @experimental
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vitepress",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Vite & Vue powered static site generator",
|
|
5
5
|
"main": "dist/node/index.js",
|
|
6
6
|
"typings": "types/index.d.ts",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"files": [
|
|
11
11
|
"bin",
|
|
12
12
|
"dist",
|
|
13
|
-
"types"
|
|
13
|
+
"types",
|
|
14
|
+
"client.d.ts"
|
|
14
15
|
],
|
|
15
16
|
"engines": {
|
|
16
17
|
"node": ">=12.0.0"
|
|
@@ -130,5 +131,6 @@
|
|
|
130
131
|
"docs-build": "npm run build && node ./bin/vitepress build docs",
|
|
131
132
|
"docs-serve": "node ./bin/vitepress serve docs",
|
|
132
133
|
"ci-docs": "run-s build docs-build"
|
|
133
|
-
}
|
|
134
|
+
},
|
|
135
|
+
"readme": "# (WIP) VitePress 📝💨\n\n[](https://github.com/vuejs/vitepress/actions)\n[](https://www.npmjs.com/package/vitepress)\n\n---\n\nVitePress is [VuePress](http://vuepress.vuejs.org/)' spiritual successor, built on top of [vite](https://github.com/vuejs/vite).\n\n## Documentation\n\nTo check out docs, visit [vitepress.vuejs.org](https://vitepress.vuejs.org).\n\n## Changelog\n\nDetailed changes for each release are documented in the [CHANGELOG](https://github.com/vuejs/vitepress/blob/master/CHANGELOG.md).\n\n## Contribution\n\nPlease make sure to read the [Contributing Guide](./.github/contributing.md) before making a pull request.\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n\nCopyright (c) 2019-present, Yuxi (Evan) You\n"
|
|
134
136
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
export namespace DefaultTheme {
|
|
2
|
+
export interface Config {
|
|
3
|
+
logo?: string
|
|
4
|
+
nav?: NavItem[] | false
|
|
5
|
+
sidebar?: SideBarConfig | MultiSideBarConfig
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* GitHub repository following the format <user>/<project>.
|
|
9
|
+
*
|
|
10
|
+
* @example `"vuejs/vue-next"`
|
|
11
|
+
*/
|
|
12
|
+
repo?: string
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Customize the header label. Defaults to GitHub/Gitlab/Bitbucket
|
|
16
|
+
* depending on the provided repo.
|
|
17
|
+
*
|
|
18
|
+
* @example `"Contribute!"`
|
|
19
|
+
*/
|
|
20
|
+
repoLabel?: string
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* If your docs are in a different repository from your main project.
|
|
24
|
+
*
|
|
25
|
+
* @example `"vuejs/docs-next"`
|
|
26
|
+
*/
|
|
27
|
+
docsRepo?: string
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* If your docs are not at the root of the repo.
|
|
31
|
+
*
|
|
32
|
+
* @example `"docs"`
|
|
33
|
+
*/
|
|
34
|
+
docsDir?: string
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* If your docs are in a different branch. Defaults to `master`.
|
|
38
|
+
*
|
|
39
|
+
* @example `"next"`
|
|
40
|
+
*/
|
|
41
|
+
docsBranch?: string
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Enable links to edit pages at the bottom of the page.
|
|
45
|
+
*/
|
|
46
|
+
editLinks?: boolean
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Custom text for edit link. Defaults to "Edit this page".
|
|
50
|
+
*/
|
|
51
|
+
editLinkText?: string
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Show last updated time at the bottom of the page. Defaults to `false`.
|
|
55
|
+
* If given a string, it will be displayed as a prefix (default value:
|
|
56
|
+
* "Last Updated").
|
|
57
|
+
*/
|
|
58
|
+
lastUpdated?: string | boolean
|
|
59
|
+
|
|
60
|
+
prevLinks?: boolean
|
|
61
|
+
nextLinks?: boolean
|
|
62
|
+
|
|
63
|
+
locales?: Record<string, LocaleConfig & Omit<Config, 'locales'>>
|
|
64
|
+
|
|
65
|
+
algolia?: AlgoliaSearchOptions
|
|
66
|
+
|
|
67
|
+
carbonAds?: {
|
|
68
|
+
carbon: string
|
|
69
|
+
custom?: string
|
|
70
|
+
placement: string
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// navbar --------------------------------------------------------------------
|
|
75
|
+
|
|
76
|
+
export type NavItem = NavItemWithLink | NavItemWithChildren
|
|
77
|
+
|
|
78
|
+
export interface NavItemBase {
|
|
79
|
+
text: string
|
|
80
|
+
target?: string
|
|
81
|
+
rel?: string
|
|
82
|
+
ariaLabel?: string
|
|
83
|
+
activeMatch?: string
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface NavItemWithLink extends NavItemBase {
|
|
87
|
+
link: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface NavItemWithChildren extends NavItemBase {
|
|
91
|
+
items: NavItemWithLink[]
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// sidebar -------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
export type SideBarConfig = SideBarItem[] | 'auto' | false
|
|
97
|
+
|
|
98
|
+
export interface MultiSideBarConfig {
|
|
99
|
+
[path: string]: SideBarConfig
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export type SideBarItem = SideBarLink | SideBarGroup
|
|
103
|
+
|
|
104
|
+
export interface SideBarLink {
|
|
105
|
+
text: string
|
|
106
|
+
link: string
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface SideBarGroup {
|
|
110
|
+
text: string
|
|
111
|
+
link?: string
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* @default false
|
|
115
|
+
*/
|
|
116
|
+
collapsable?: boolean
|
|
117
|
+
|
|
118
|
+
children: SideBarItem[]
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// algolia ------------------------------------------------------------------
|
|
122
|
+
// partially copied from @docsearch/react/dist/esm/DocSearch.d.ts
|
|
123
|
+
export interface AlgoliaSearchOptions {
|
|
124
|
+
appId?: string
|
|
125
|
+
apiKey: string
|
|
126
|
+
indexName: string
|
|
127
|
+
placeholder?: string
|
|
128
|
+
searchParameters?: any
|
|
129
|
+
disableUserPersonalization?: boolean
|
|
130
|
+
initialQuery?: string
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// locales -------------------------------------------------------------------
|
|
134
|
+
|
|
135
|
+
export interface LocaleConfig {
|
|
136
|
+
/**
|
|
137
|
+
* Text for the language dropdown.
|
|
138
|
+
*/
|
|
139
|
+
selectText?: string
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Label for this locale in the language dropdown.
|
|
143
|
+
*/
|
|
144
|
+
label?: string
|
|
145
|
+
}
|
|
146
|
+
}
|
package/types/index.d.ts
CHANGED