vitepress 0.20.10 → 0.21.3
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/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 +160 -9
- package/dist/node/index.js +2 -1
- package/dist/node/{serve-b109daa0.js → serve-d0483577.js} +96 -39
- package/dist/vitepress.d.ts +160 -9
- package/package.json +1 -1
- package/types/default-theme.d.ts +146 -0
- package/types/index.d.ts +0 -2
- package/types/shared.d.ts +18 -16
|
@@ -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
|
|
|
@@ -130,7 +280,7 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
130
280
|
}
|
|
131
281
|
|
|
132
282
|
export declare interface UserConfig<ThemeConfig = any> {
|
|
133
|
-
extends?: RawConfigExports
|
|
283
|
+
extends?: RawConfigExports<ThemeConfig>;
|
|
134
284
|
lang?: string;
|
|
135
285
|
base?: string;
|
|
136
286
|
title?: string;
|
|
@@ -140,7 +290,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
140
290
|
locales?: Record<string, LocaleConfig>;
|
|
141
291
|
markdown?: MarkdownOptions;
|
|
142
292
|
/**
|
|
143
|
-
*
|
|
293
|
+
* Options to pass on to `@vitejs/plugin-vue`
|
|
144
294
|
*/
|
|
145
295
|
vue?: Options;
|
|
146
296
|
/**
|
|
@@ -149,6 +299,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
149
299
|
vite?: UserConfig_2;
|
|
150
300
|
srcDir?: string;
|
|
151
301
|
srcExclude?: string[];
|
|
302
|
+
outDir?: string;
|
|
152
303
|
shouldPreload?: (link: string, page: string) => boolean;
|
|
153
304
|
/**
|
|
154
305
|
* Enable MPA / zero-JS mode
|
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-d0483577.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;
|
|
@@ -12306,12 +12306,19 @@ const SHARED_PATH = path__default["default"].join(DIST_CLIENT_PATH, "shared");
|
|
|
12306
12306
|
const DEFAULT_THEME_PATH = path__default["default"].join(DIST_CLIENT_PATH, "theme-default");
|
|
12307
12307
|
const SITE_DATA_ID = "@siteData";
|
|
12308
12308
|
const SITE_DATA_REQUEST_PATH = "/" + SITE_DATA_ID;
|
|
12309
|
-
|
|
12309
|
+
const vueRuntimePath = "vue/dist/vue.runtime.esm-bundler.js";
|
|
12310
|
+
function resolveAliases(root, themeDir) {
|
|
12310
12311
|
const paths = {
|
|
12311
12312
|
"/@theme": themeDir,
|
|
12312
12313
|
"/@shared": SHARED_PATH,
|
|
12313
12314
|
[SITE_DATA_ID]: SITE_DATA_REQUEST_PATH
|
|
12314
12315
|
};
|
|
12316
|
+
let vuePath;
|
|
12317
|
+
try {
|
|
12318
|
+
vuePath = require.resolve(vueRuntimePath, { paths: [root] });
|
|
12319
|
+
} catch (e) {
|
|
12320
|
+
vuePath = require.resolve(vueRuntimePath);
|
|
12321
|
+
}
|
|
12315
12322
|
const aliases = [
|
|
12316
12323
|
...Object.keys(paths).map((p) => ({
|
|
12317
12324
|
find: p,
|
|
@@ -12328,7 +12335,7 @@ function resolveAliases(themeDir) {
|
|
|
12328
12335
|
{ find: /^vitepress\//, replacement: PKG_ROOT + "/" },
|
|
12329
12336
|
{
|
|
12330
12337
|
find: /^vue$/,
|
|
12331
|
-
replacement:
|
|
12338
|
+
replacement: vuePath
|
|
12332
12339
|
}
|
|
12333
12340
|
];
|
|
12334
12341
|
return aliases;
|
|
@@ -13349,10 +13356,14 @@ const resolve = (root, file) => vite.normalizePath(path__default["default"].reso
|
|
|
13349
13356
|
function defineConfig(config) {
|
|
13350
13357
|
return config;
|
|
13351
13358
|
}
|
|
13359
|
+
function defineConfigWithTheme(config) {
|
|
13360
|
+
return config;
|
|
13361
|
+
}
|
|
13352
13362
|
async function resolveConfig(root = process.cwd(), command = "serve", mode = "development") {
|
|
13353
13363
|
const [userConfig, configPath] = await resolveUserConfig(root, command, mode);
|
|
13354
13364
|
const site = await resolveSiteData(root, userConfig);
|
|
13355
13365
|
const srcDir = path__default["default"].resolve(root, userConfig.srcDir || ".");
|
|
13366
|
+
const outDir = userConfig.outDir ? path__default["default"].resolve(root, userConfig.outDir) : resolve(root, "dist");
|
|
13356
13367
|
const userThemeDir = resolve(root, "theme");
|
|
13357
13368
|
const themeDir = await lib$1.pathExists(userThemeDir) ? userThemeDir : DEFAULT_THEME_PATH;
|
|
13358
13369
|
const pages = (await globby(["**.md"], {
|
|
@@ -13366,10 +13377,10 @@ async function resolveConfig(root = process.cwd(), command = "serve", mode = "de
|
|
|
13366
13377
|
themeDir,
|
|
13367
13378
|
pages,
|
|
13368
13379
|
configPath,
|
|
13369
|
-
outDir
|
|
13370
|
-
tempDir:
|
|
13380
|
+
outDir,
|
|
13381
|
+
tempDir: resolve(root, ".temp"),
|
|
13371
13382
|
markdown: userConfig.markdown,
|
|
13372
|
-
alias: resolveAliases(themeDir),
|
|
13383
|
+
alias: resolveAliases(root, themeDir),
|
|
13373
13384
|
vue: userConfig.vue,
|
|
13374
13385
|
vite: userConfig.vite,
|
|
13375
13386
|
shouldPreload: userConfig.shouldPreload,
|
|
@@ -13377,7 +13388,7 @@ async function resolveConfig(root = process.cwd(), command = "serve", mode = "de
|
|
|
13377
13388
|
};
|
|
13378
13389
|
return config;
|
|
13379
13390
|
}
|
|
13380
|
-
const supportedConfigExtensions = ["js", "ts", "
|
|
13391
|
+
const supportedConfigExtensions = ["js", "ts", "mjs", "mts"];
|
|
13381
13392
|
async function resolveUserConfig(root, command, mode) {
|
|
13382
13393
|
var _a;
|
|
13383
13394
|
let configPath;
|
|
@@ -34187,10 +34198,11 @@ var require$$0$4 = {
|
|
|
34187
34198
|
};
|
|
34188
34199
|
|
|
34189
34200
|
const parseEmojis = (str) => {
|
|
34190
|
-
return
|
|
34201
|
+
return str.replace(/:(.+?):/g, (placeholder, key) => require$$0$4[key] || placeholder);
|
|
34191
34202
|
};
|
|
34192
|
-
const unescapeHtml = (html) =>
|
|
34193
|
-
const removeMarkdownTokens = (str) =>
|
|
34203
|
+
const unescapeHtml = (html) => html.replace(/"/g, '"').replace(/'/g, "'").replace(/:/g, ":").replace(/</g, "<").replace(/>/g, ">");
|
|
34204
|
+
const removeMarkdownTokens = (str) => str.replace(/(\[(.[^\]]+)\]\((.[^)]+)\))/g, "$2").replace(/(`|\*{1,3}|_)(.*?[^\\])\1/g, "$2").replace(/(\\)(\*|_|`|\!|<|\$)/g, "$2");
|
|
34205
|
+
const remvoeCustomAnchor = (str) => str.replace(/\{#([a-z0-9\-_]+?)\}\s*$/, "");
|
|
34194
34206
|
const trim = (str) => str.trim();
|
|
34195
34207
|
const removeNonCodeWrappedHTML = (str) => {
|
|
34196
34208
|
return String(str).replace(/(^|[^><`\\])<.*>([^><`]|$)/g, "$1$2");
|
|
@@ -34204,7 +34216,7 @@ const compose = (...processors) => {
|
|
|
34204
34216
|
return (str) => next(prev(str));
|
|
34205
34217
|
});
|
|
34206
34218
|
};
|
|
34207
|
-
const parseHeader = compose(unescapeHtml, parseEmojis, removeMarkdownTokens, trim);
|
|
34219
|
+
const parseHeader = compose(unescapeHtml, parseEmojis, remvoeCustomAnchor, removeMarkdownTokens, trim);
|
|
34208
34220
|
const deeplyParseHeader = compose(removeNonCodeWrappedHTML, parseHeader);
|
|
34209
34221
|
|
|
34210
34222
|
/*!
|
|
@@ -34901,7 +34913,7 @@ var markdownItContainer = function container_plugin(md, name, options) {
|
|
|
34901
34913
|
};
|
|
34902
34914
|
|
|
34903
34915
|
const containerPlugin = (md) => {
|
|
34904
|
-
md.use(...createContainer("tip", "TIP")).use(...createContainer("info", "INFO")).use(...createContainer("warning", "WARNING")).use(...createContainer("danger", "WARNING")).use(markdownItContainer, "v-pre", {
|
|
34916
|
+
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", {
|
|
34905
34917
|
render: (tokens, idx) => tokens[idx].nesting === 1 ? `<div v-pre>
|
|
34906
34918
|
` : `</div>
|
|
34907
34919
|
`
|
|
@@ -34916,10 +34928,15 @@ function createContainer(klass, defaultTitle) {
|
|
|
34916
34928
|
const token = tokens[idx];
|
|
34917
34929
|
const info = token.info.trim().slice(klass.length).trim();
|
|
34918
34930
|
if (token.nesting === 1) {
|
|
34931
|
+
if (klass === "details") {
|
|
34932
|
+
return `<details class="${klass} custom-block">${info ? `<summary>${info}</summary>` : ""}
|
|
34933
|
+
`;
|
|
34934
|
+
}
|
|
34919
34935
|
return `<div class="${klass} custom-block"><p class="custom-block-title">${info || defaultTitle}</p>
|
|
34920
34936
|
`;
|
|
34921
34937
|
} else {
|
|
34922
|
-
return `</
|
|
34938
|
+
return klass === "details" ? `</details>
|
|
34939
|
+
` : `</div>
|
|
34923
34940
|
`;
|
|
34924
34941
|
}
|
|
34925
34942
|
}
|
|
@@ -35075,6 +35092,9 @@ const linkPlugin = (md, externalAttrs) => {
|
|
|
35075
35092
|
Object.entries(externalAttrs).forEach(([key, val]) => {
|
|
35076
35093
|
token.attrSet(key, val);
|
|
35077
35094
|
});
|
|
35095
|
+
if (url.replace(EXTERNAL_URL_RE, "").startsWith("//localhost:")) {
|
|
35096
|
+
pushLink(url);
|
|
35097
|
+
}
|
|
35078
35098
|
} else if (!url.startsWith("#") && !url.startsWith("mailto:")) {
|
|
35079
35099
|
normalizeHref(hrefAttr);
|
|
35080
35100
|
}
|
|
@@ -35102,14 +35122,17 @@ const linkPlugin = (md, externalAttrs) => {
|
|
|
35102
35122
|
if (!url.startsWith("/") && !/^\.\//.test(url)) {
|
|
35103
35123
|
url = "./" + url;
|
|
35104
35124
|
}
|
|
35125
|
+
pushLink(url.replace(/\.html$/, ""));
|
|
35126
|
+
hrefAttr[1] = decodeURI(url);
|
|
35127
|
+
}
|
|
35128
|
+
function pushLink(link) {
|
|
35105
35129
|
const data = md.__data;
|
|
35106
35130
|
const links = data.links || (data.links = []);
|
|
35107
|
-
links.push(
|
|
35108
|
-
hrefAttr[1] = decodeURI(url);
|
|
35131
|
+
links.push(link);
|
|
35109
35132
|
}
|
|
35110
35133
|
};
|
|
35111
35134
|
|
|
35112
|
-
const
|
|
35135
|
+
const headingPlugin = (md, include = ["h2", "h3"]) => {
|
|
35113
35136
|
md.renderer.rules.heading_open = (tokens, i, options, env, self) => {
|
|
35114
35137
|
const token = tokens[i];
|
|
35115
35138
|
if (include.includes(token.tag)) {
|
|
@@ -36278,7 +36301,7 @@ const createMarkdownRenderer = (srcDir, options = {}) => {
|
|
|
36278
36301
|
linkify: true,
|
|
36279
36302
|
highlight
|
|
36280
36303
|
}, options));
|
|
36281
|
-
md.use(componentPlugin).use(highlightLinePlugin).use(preWrapperPlugin).use(snippetPlugin, srcDir).use(hoistPlugin).use(containerPlugin).use(
|
|
36304
|
+
md.use(componentPlugin).use(highlightLinePlugin).use(preWrapperPlugin).use(snippetPlugin, srcDir).use(hoistPlugin).use(containerPlugin).use(headingPlugin).use(linkPlugin, __spreadValues$2({
|
|
36282
36305
|
target: "_blank",
|
|
36283
36306
|
rel: "noopener noreferrer"
|
|
36284
36307
|
}, options.externalLinks)).use(markdownItAttrs, options.attrs).use(b, __spreadValues$2({
|
|
@@ -36295,16 +36318,6 @@ const createMarkdownRenderer = (srcDir, options = {}) => {
|
|
|
36295
36318
|
if (options.lineNumbers) {
|
|
36296
36319
|
md.use(lineNumberPlugin);
|
|
36297
36320
|
}
|
|
36298
|
-
const render = md.render;
|
|
36299
|
-
const wrappedRender = (src) => {
|
|
36300
|
-
md.__data = {};
|
|
36301
|
-
const html = render.call(md, src);
|
|
36302
|
-
return {
|
|
36303
|
-
html,
|
|
36304
|
-
data: md.__data
|
|
36305
|
-
};
|
|
36306
|
-
};
|
|
36307
|
-
md.render = wrappedRender;
|
|
36308
36321
|
return md;
|
|
36309
36322
|
};
|
|
36310
36323
|
|
|
@@ -36336,7 +36349,11 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36336
36349
|
return content2;
|
|
36337
36350
|
});
|
|
36338
36351
|
const { content, data: frontmatter } = grayMatter(src);
|
|
36339
|
-
|
|
36352
|
+
md.__path = file;
|
|
36353
|
+
md.__relativePath = relativePath;
|
|
36354
|
+
md.__data = {};
|
|
36355
|
+
let html = md.render(content);
|
|
36356
|
+
const data = md.__data;
|
|
36340
36357
|
if (isBuild) {
|
|
36341
36358
|
html = html.replace(/\bimport\.meta/g, "import.<wbr/>meta").replace(/\bprocess\.env/g, "process.<wbr/>env");
|
|
36342
36359
|
if (userDefineRegex) {
|
|
@@ -36344,17 +36361,24 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36344
36361
|
}
|
|
36345
36362
|
}
|
|
36346
36363
|
const deadLinks = [];
|
|
36364
|
+
const recordDeadLink = (url) => {
|
|
36365
|
+
console.warn(source.yellow(`
|
|
36366
|
+
(!) Found dead link ${source.cyan(url)} in file ${source.white.dim(file)}`));
|
|
36367
|
+
deadLinks.push(url);
|
|
36368
|
+
};
|
|
36347
36369
|
if (data.links) {
|
|
36348
36370
|
const dir2 = path__default["default"].dirname(file);
|
|
36349
36371
|
for (let url of data.links) {
|
|
36372
|
+
if (url.replace(EXTERNAL_URL_RE, "").startsWith("//localhost:")) {
|
|
36373
|
+
recordDeadLink(url);
|
|
36374
|
+
continue;
|
|
36375
|
+
}
|
|
36350
36376
|
url = url.replace(/[?#].*$/, "").replace(/\.(html|md)$/, "");
|
|
36351
36377
|
if (url.endsWith("/"))
|
|
36352
36378
|
url += `index`;
|
|
36353
|
-
const resolved = slash(url.startsWith("/") ? url.slice(1) : path__default["default"].relative(srcDir, path__default["default"].resolve(dir2, url)));
|
|
36379
|
+
const resolved = decodeURIComponent(slash(url.startsWith("/") ? url.slice(1) : path__default["default"].relative(srcDir, path__default["default"].resolve(dir2, url))));
|
|
36354
36380
|
if (!pages.includes(resolved) && !fs__default["default"].existsSync(path__default["default"].resolve(dir2, publicDir, `${resolved}.html`))) {
|
|
36355
|
-
|
|
36356
|
-
(!) Found dead link ${source.cyan(url)} in file ${source.white.dim(file)}`));
|
|
36357
|
-
deadLinks.push(url);
|
|
36381
|
+
recordDeadLink(url);
|
|
36358
36382
|
}
|
|
36359
36383
|
}
|
|
36360
36384
|
}
|
|
@@ -36362,7 +36386,7 @@ function createMarkdownToVueRenderFn(srcDir, options = {}, pages, userDefines, i
|
|
|
36362
36386
|
title: inferTitle(frontmatter, content),
|
|
36363
36387
|
description: inferDescription(frontmatter),
|
|
36364
36388
|
frontmatter,
|
|
36365
|
-
headers: data.headers,
|
|
36389
|
+
headers: data.headers || [],
|
|
36366
36390
|
relativePath,
|
|
36367
36391
|
lastUpdated: Math.round(fs__default["default"].statSync(file).mtimeMs)
|
|
36368
36392
|
};
|
|
@@ -36594,7 +36618,11 @@ function createVitePressPlugin(root, siteConfig, ssr = false, pageToHashMap, cli
|
|
|
36594
36618
|
},
|
|
36595
36619
|
load(id) {
|
|
36596
36620
|
if (id === SITE_DATA_REQUEST_PATH) {
|
|
36597
|
-
|
|
36621
|
+
let data = siteData;
|
|
36622
|
+
if (config.command === "build") {
|
|
36623
|
+
data = __spreadProps$1(__spreadValues$1({}, siteData), { head: [] });
|
|
36624
|
+
}
|
|
36625
|
+
return `export default ${JSON.stringify(JSON.stringify(data))}`;
|
|
36598
36626
|
}
|
|
36599
36627
|
},
|
|
36600
36628
|
transform(code, id) {
|
|
@@ -40035,7 +40063,15 @@ async function renderPage(config, page, result, appChunk, cssChunk, pageToHashMa
|
|
|
40035
40063
|
const routePath = `/${page.replace(/\.md$/, "")}`;
|
|
40036
40064
|
const siteData = resolveSiteDataByRoute(config.site, routePath);
|
|
40037
40065
|
router.go(routePath);
|
|
40038
|
-
|
|
40066
|
+
let rendererPath;
|
|
40067
|
+
try {
|
|
40068
|
+
rendererPath = require.resolve("vue/server-renderer", {
|
|
40069
|
+
paths: [config.root]
|
|
40070
|
+
});
|
|
40071
|
+
} catch (e) {
|
|
40072
|
+
rendererPath = require.resolve("vue/server-renderer");
|
|
40073
|
+
}
|
|
40074
|
+
const content = await require(rendererPath).renderToString(app);
|
|
40039
40075
|
const pageName = page.replace(/\//g, "_");
|
|
40040
40076
|
const pageServerJsFileName = pageName + ".js";
|
|
40041
40077
|
const pageHash = pageToHashMap[pageName.toLowerCase()];
|
|
@@ -65095,9 +65131,20 @@ class Polka extends Router {
|
|
|
65095
65131
|
|
|
65096
65132
|
var polka = opts => new Polka(opts);
|
|
65097
65133
|
|
|
65134
|
+
function trimChar(str, char) {
|
|
65135
|
+
while (str.charAt(0) === char) {
|
|
65136
|
+
str = str.substring(1);
|
|
65137
|
+
}
|
|
65138
|
+
while (str.charAt(str.length - 1) === char) {
|
|
65139
|
+
str = str.substring(0, str.length - 1);
|
|
65140
|
+
}
|
|
65141
|
+
return str;
|
|
65142
|
+
}
|
|
65098
65143
|
async function serve(options = {}) {
|
|
65144
|
+
var _a, _b;
|
|
65099
65145
|
const port = options.port !== void 0 ? options.port : 5e3;
|
|
65100
65146
|
const site = await resolveConfig(options.root, "serve", "production");
|
|
65147
|
+
const base = trimChar((_b = (_a = site == null ? void 0 : site.site) == null ? void 0 : _a.base) != null ? _b : "", "/");
|
|
65101
65148
|
const compress = compression$1();
|
|
65102
65149
|
const serve2 = sirv(site.outDir, {
|
|
65103
65150
|
etag: true,
|
|
@@ -65110,18 +65157,28 @@ async function serve(options = {}) {
|
|
|
65110
65157
|
}
|
|
65111
65158
|
}
|
|
65112
65159
|
});
|
|
65113
|
-
|
|
65114
|
-
|
|
65115
|
-
|
|
65116
|
-
|
|
65160
|
+
if (base) {
|
|
65161
|
+
polka().use(base, compress, serve2).listen(port, (err) => {
|
|
65162
|
+
if (err)
|
|
65163
|
+
throw err;
|
|
65164
|
+
console.log(`Built site served at http://localhost:${port}/${base}/
|
|
65117
65165
|
`);
|
|
65118
|
-
|
|
65166
|
+
});
|
|
65167
|
+
} else {
|
|
65168
|
+
polka().use(compress, serve2).listen(port, (err) => {
|
|
65169
|
+
if (err)
|
|
65170
|
+
throw err;
|
|
65171
|
+
console.log(`Built site served at http://localhost:${port}/
|
|
65172
|
+
`);
|
|
65173
|
+
});
|
|
65174
|
+
}
|
|
65119
65175
|
}
|
|
65120
65176
|
|
|
65121
65177
|
exports.build = build;
|
|
65122
65178
|
exports.createMarkdownRenderer = createMarkdownRenderer;
|
|
65123
65179
|
exports.createServer = createServer;
|
|
65124
65180
|
exports.defineConfig = defineConfig;
|
|
65181
|
+
exports.defineConfigWithTheme = defineConfigWithTheme;
|
|
65125
65182
|
exports.resolveConfig = resolveConfig;
|
|
65126
65183
|
exports.resolveSiteData = resolveSiteData;
|
|
65127
65184
|
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
|
|
|
@@ -130,7 +280,7 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
130
280
|
}
|
|
131
281
|
|
|
132
282
|
export declare interface UserConfig<ThemeConfig = any> {
|
|
133
|
-
extends?: RawConfigExports
|
|
283
|
+
extends?: RawConfigExports<ThemeConfig>;
|
|
134
284
|
lang?: string;
|
|
135
285
|
base?: string;
|
|
136
286
|
title?: string;
|
|
@@ -140,7 +290,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
140
290
|
locales?: Record<string, LocaleConfig>;
|
|
141
291
|
markdown?: MarkdownOptions;
|
|
142
292
|
/**
|
|
143
|
-
*
|
|
293
|
+
* Options to pass on to `@vitejs/plugin-vue`
|
|
144
294
|
*/
|
|
145
295
|
vue?: Options;
|
|
146
296
|
/**
|
|
@@ -149,6 +299,7 @@ export declare interface UserConfig<ThemeConfig = any> {
|
|
|
149
299
|
vite?: UserConfig_2;
|
|
150
300
|
srcDir?: string;
|
|
151
301
|
srcExclude?: string[];
|
|
302
|
+
outDir?: string;
|
|
152
303
|
shouldPreload?: (link: string, page: string) => boolean;
|
|
153
304
|
/**
|
|
154
305
|
* Enable MPA / zero-JS mode
|
package/package.json
CHANGED
|
@@ -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
package/types/shared.d.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
// types shared between server and client
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
3
|
+
export { DefaultTheme } from './default-theme'
|
|
4
|
+
|
|
5
|
+
export interface PageData {
|
|
6
|
+
relativePath: string
|
|
7
|
+
title: string
|
|
8
|
+
description: string
|
|
9
|
+
headers: Header[]
|
|
10
|
+
frontmatter: Record<string, any>
|
|
11
|
+
lastUpdated: number
|
|
10
12
|
}
|
|
11
13
|
|
|
12
14
|
export interface SiteData<ThemeConfig = any> {
|
|
@@ -47,17 +49,17 @@ export type HeadConfig =
|
|
|
47
49
|
| [string, Record<string, string>]
|
|
48
50
|
| [string, Record<string, string>, string]
|
|
49
51
|
|
|
50
|
-
export interface PageData {
|
|
51
|
-
relativePath: string
|
|
52
|
-
title: string
|
|
53
|
-
description: string
|
|
54
|
-
headers: Header[]
|
|
55
|
-
frontmatter: Record<string, any>
|
|
56
|
-
lastUpdated: number
|
|
57
|
-
}
|
|
58
|
-
|
|
59
52
|
export interface Header {
|
|
60
53
|
level: number
|
|
61
54
|
title: string
|
|
62
55
|
slug: string
|
|
63
56
|
}
|
|
57
|
+
|
|
58
|
+
export interface LocaleConfig {
|
|
59
|
+
lang: string
|
|
60
|
+
title?: string
|
|
61
|
+
description?: string
|
|
62
|
+
head?: HeadConfig[]
|
|
63
|
+
label?: string
|
|
64
|
+
selectText?: string
|
|
65
|
+
}
|