vitepress 0.19.2 → 0.20.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 +16 -4
- package/dist/client/index.d.ts +100 -64
- package/dist/client/theme-default/Layout.vue +16 -12
- package/dist/client/theme-default/components/AlgoliaSearchBox.vue +29 -12
- package/dist/client/theme-default/composables/navLink.js +1 -1
- package/dist/client/theme-default/styles/code.css +1 -1
- package/dist/node/cli.js +8 -6
- package/dist/node/index.js +3 -3
- package/dist/node/{serve-5d08e165.js → serve-f83deb60.js} +11006 -382
- package/dist/{node/index.d.ts → vitepress.d.ts} +32 -7
- package/package.json +36 -36
- package/CHANGELOG.md +0 -625
|
@@ -53,7 +53,13 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
53
53
|
if (inBrowser) {
|
|
54
54
|
nextTick(() => {
|
|
55
55
|
if (targetLoc.hash && !scrollPosition) {
|
|
56
|
-
|
|
56
|
+
let target = null;
|
|
57
|
+
try {
|
|
58
|
+
target = document.querySelector(decodeURIComponent(targetLoc.hash));
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
console.warn(e);
|
|
62
|
+
}
|
|
57
63
|
if (target) {
|
|
58
64
|
scrollTo(target, targetLoc.hash);
|
|
59
65
|
return;
|
|
@@ -132,9 +138,15 @@ export function useRoute() {
|
|
|
132
138
|
return useRouter().route;
|
|
133
139
|
}
|
|
134
140
|
function scrollTo(el, hash, smooth = false) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
141
|
+
let target = null;
|
|
142
|
+
try {
|
|
143
|
+
target = el.classList.contains('.header-anchor')
|
|
144
|
+
? el
|
|
145
|
+
: document.querySelector(decodeURIComponent(hash));
|
|
146
|
+
}
|
|
147
|
+
catch (e) {
|
|
148
|
+
console.warn(e);
|
|
149
|
+
}
|
|
138
150
|
if (target) {
|
|
139
151
|
const targetTop = target.offsetTop;
|
|
140
152
|
// only smooth scroll if distance is smaller than screen height.
|
package/dist/client/index.d.ts
CHANGED
|
@@ -1,28 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export declare
|
|
22
|
-
app: App;
|
|
23
|
-
router: Router;
|
|
24
|
-
siteData: Ref<SiteData>;
|
|
25
|
-
}
|
|
1
|
+
import { AliasOptions } from 'vite';
|
|
2
|
+
import anchor from 'markdown-it-anchor';
|
|
3
|
+
import { BuildOptions } from 'vite';
|
|
4
|
+
import MarkdownIt from 'markdown-it';
|
|
5
|
+
import { Options } from '@vitejs/plugin-vue';
|
|
6
|
+
import { ServerOptions } from 'vite';
|
|
7
|
+
import { UserConfig as UserConfig_2 } from 'vite';
|
|
8
|
+
import { ViteDevServer } from 'vite';
|
|
9
|
+
|
|
10
|
+
export declare function build(root: string, buildOptions?: BuildOptions & {
|
|
11
|
+
mpa?: string;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
|
|
14
|
+
export declare const createMarkdownRenderer: (srcDir: string, options?: MarkdownOptions) => MarkdownRenderer;
|
|
15
|
+
|
|
16
|
+
export declare function createServer(root?: string, serverOptions?: ServerOptions): Promise<ViteDevServer>;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Type config helper
|
|
20
|
+
*/
|
|
21
|
+
export declare function defineConfig(config: RawConfigExports): RawConfigExports;
|
|
26
22
|
|
|
27
23
|
export declare type HeadConfig =
|
|
28
24
|
| [string, Record<string, string>]
|
|
@@ -34,8 +30,6 @@ export declare interface Header {
|
|
|
34
30
|
slug: string
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
export declare const inBrowser: boolean;
|
|
38
|
-
|
|
39
33
|
export declare interface LocaleConfig {
|
|
40
34
|
lang: string
|
|
41
35
|
title?: string
|
|
@@ -45,24 +39,64 @@ export declare interface LocaleConfig {
|
|
|
45
39
|
selectText?: string
|
|
46
40
|
}
|
|
47
41
|
|
|
48
|
-
export declare interface
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
42
|
+
export declare interface MarkdownOptions extends MarkdownIt.Options {
|
|
43
|
+
lineNumbers?: boolean;
|
|
44
|
+
config?: (md: MarkdownIt) => void;
|
|
45
|
+
anchor?: {
|
|
46
|
+
permalink?: anchor.AnchorOptions['permalink'];
|
|
47
|
+
};
|
|
48
|
+
attrs?: {
|
|
49
|
+
leftDelimiter?: string;
|
|
50
|
+
rightDelimiter?: string;
|
|
51
|
+
allowedAttributes?: string[];
|
|
52
|
+
};
|
|
53
|
+
toc?: any;
|
|
54
|
+
externalLinks?: Record<string, string>;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
export declare interface
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
57
|
+
export declare interface MarkdownParsedData {
|
|
58
|
+
hoistedTags?: string[];
|
|
59
|
+
links?: string[];
|
|
60
|
+
headers?: Header[];
|
|
61
61
|
}
|
|
62
62
|
|
|
63
|
-
export declare interface
|
|
64
|
-
|
|
65
|
-
|
|
63
|
+
export declare interface MarkdownRenderer {
|
|
64
|
+
__data: MarkdownParsedData;
|
|
65
|
+
render: (src: string, env?: any) => {
|
|
66
|
+
html: string;
|
|
67
|
+
data: any;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export declare type RawConfigExports = UserConfig | Promise<UserConfig> | (() => UserConfig | Promise<UserConfig>);
|
|
72
|
+
|
|
73
|
+
export declare function resolveConfig(root?: string, command?: 'serve' | 'build', mode?: string): Promise<SiteConfig>;
|
|
74
|
+
|
|
75
|
+
export declare function resolveSiteData(root: string, userConfig?: UserConfig, command?: 'serve' | 'build', mode?: string): Promise<SiteData>;
|
|
76
|
+
|
|
77
|
+
export declare function resolveSiteDataByRoute(siteData: SiteData, route: string): SiteData;
|
|
78
|
+
|
|
79
|
+
export declare function serve(options?: ServeOptions): Promise<void>;
|
|
80
|
+
|
|
81
|
+
export declare interface ServeOptions {
|
|
82
|
+
root?: string;
|
|
83
|
+
port?: number;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export declare interface SiteConfig<ThemeConfig = any> {
|
|
87
|
+
root: string;
|
|
88
|
+
srcDir: string;
|
|
89
|
+
site: SiteData<ThemeConfig>;
|
|
90
|
+
configPath: string | undefined;
|
|
91
|
+
themeDir: string;
|
|
92
|
+
outDir: string;
|
|
93
|
+
tempDir: string;
|
|
94
|
+
alias: AliasOptions;
|
|
95
|
+
pages: string[];
|
|
96
|
+
markdown: MarkdownOptions | undefined;
|
|
97
|
+
vue: Options | undefined;
|
|
98
|
+
vite: UserConfig_2 | undefined;
|
|
99
|
+
mpa: boolean;
|
|
66
100
|
}
|
|
67
101
|
|
|
68
102
|
export declare interface SiteData<ThemeConfig = any> {
|
|
@@ -99,29 +133,31 @@ export declare interface SiteData<ThemeConfig = any> {
|
|
|
99
133
|
>
|
|
100
134
|
}
|
|
101
135
|
|
|
102
|
-
export declare interface
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
136
|
+
export declare interface UserConfig<ThemeConfig = any> {
|
|
137
|
+
extends?: RawConfigExports;
|
|
138
|
+
lang?: string;
|
|
139
|
+
base?: string;
|
|
140
|
+
title?: string;
|
|
141
|
+
description?: string;
|
|
142
|
+
head?: HeadConfig[];
|
|
143
|
+
themeConfig?: ThemeConfig;
|
|
144
|
+
locales?: Record<string, LocaleConfig>;
|
|
145
|
+
markdown?: MarkdownOptions;
|
|
146
|
+
/**
|
|
147
|
+
* Opitons to pass on to `@vitejs/plugin-vue`
|
|
148
|
+
*/
|
|
149
|
+
vue?: Options;
|
|
150
|
+
/**
|
|
151
|
+
* Vite config
|
|
152
|
+
*/
|
|
153
|
+
vite?: UserConfig_2;
|
|
154
|
+
srcDir?: string;
|
|
155
|
+
srcExclude?: string[];
|
|
156
|
+
/**
|
|
157
|
+
* Enable MPA / zero-JS mode
|
|
158
|
+
* @experimental
|
|
159
|
+
*/
|
|
160
|
+
mpa?: boolean;
|
|
123
161
|
}
|
|
124
162
|
|
|
125
|
-
export declare function withBase(path: string): string;
|
|
126
|
-
|
|
127
163
|
export { }
|
|
@@ -89,7 +89,6 @@ const pageClasses = computed(() => {
|
|
|
89
89
|
v-if="theme.algolia"
|
|
90
90
|
:options="theme.algolia"
|
|
91
91
|
:multilang="isMultiLang"
|
|
92
|
-
:key="site.lang"
|
|
93
92
|
/>
|
|
94
93
|
</slot>
|
|
95
94
|
</template>
|
|
@@ -108,17 +107,22 @@ const pageClasses = computed(() => {
|
|
|
108
107
|
|
|
109
108
|
<Content v-if="isCustomLayout" />
|
|
110
109
|
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
110
|
+
<template v-else-if="enableHome">
|
|
111
|
+
<!-- A slot for customizing the entire homepage easily -->
|
|
112
|
+
<slot name="home">
|
|
113
|
+
<Home>
|
|
114
|
+
<template #hero>
|
|
115
|
+
<slot name="home-hero" />
|
|
116
|
+
</template>
|
|
117
|
+
<template #features>
|
|
118
|
+
<slot name="home-features" />
|
|
119
|
+
</template>
|
|
120
|
+
<template #footer>
|
|
121
|
+
<slot name="home-footer" />
|
|
122
|
+
</template>
|
|
123
|
+
</Home>
|
|
124
|
+
</slot>
|
|
125
|
+
</template>
|
|
122
126
|
|
|
123
127
|
<Page v-else>
|
|
124
128
|
<template #top>
|
|
@@ -52,11 +52,29 @@ function update(options: any) {
|
|
|
52
52
|
|
|
53
53
|
const { lang } = useData()
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
// if the user has multiple locales, the search results should be filtered
|
|
56
|
+
// based on the language
|
|
57
|
+
const facetFilters: string[] = props.multilang
|
|
58
|
+
? ['language:' + lang.value]
|
|
59
|
+
: []
|
|
60
|
+
|
|
61
|
+
if (props.options.searchParameters?.facetFilters) {
|
|
62
|
+
facetFilters.push(...props.options.searchParameters.facetFilters)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
watch(
|
|
66
|
+
lang,
|
|
67
|
+
(newLang, oldLang) => {
|
|
68
|
+
const index = facetFilters.findIndex(
|
|
69
|
+
(filter) => filter === 'language:' + oldLang
|
|
70
|
+
)
|
|
71
|
+
if (index > -1) {
|
|
72
|
+
facetFilters.splice(index, 1, 'language:' + newLang)
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
)
|
|
59
76
|
|
|
77
|
+
function initialize(userOptions: any) {
|
|
60
78
|
docsearch(
|
|
61
79
|
Object.assign({}, userOptions, {
|
|
62
80
|
container: '#docsearch',
|
|
@@ -64,23 +82,21 @@ function initialize(userOptions: any) {
|
|
|
64
82
|
searchParameters: Object.assign({}, userOptions.searchParameters, {
|
|
65
83
|
// pass a custom lang facetFilter to allow multiple language search
|
|
66
84
|
// https://github.com/algolia/docsearch-configs/pull/3942
|
|
67
|
-
facetFilters
|
|
68
|
-
userOptions.searchParameters?.facetFilters || []
|
|
69
|
-
)
|
|
85
|
+
facetFilters
|
|
70
86
|
}),
|
|
71
87
|
|
|
72
88
|
navigator: {
|
|
73
|
-
navigate: ({
|
|
89
|
+
navigate: ({ itemUrl }: { itemUrl: string }) => {
|
|
74
90
|
const { pathname: hitPathname } = new URL(
|
|
75
|
-
window.location.origin +
|
|
91
|
+
window.location.origin + itemUrl
|
|
76
92
|
)
|
|
77
93
|
|
|
78
94
|
// Router doesn't handle same-page navigation so we use the native
|
|
79
95
|
// browser location API for anchor navigation
|
|
80
96
|
if (route.path === hitPathname) {
|
|
81
|
-
window.location.assign(window.location.origin +
|
|
97
|
+
window.location.assign(window.location.origin + itemUrl)
|
|
82
98
|
} else {
|
|
83
|
-
router.go(
|
|
99
|
+
router.go(itemUrl)
|
|
84
100
|
}
|
|
85
101
|
}
|
|
86
102
|
},
|
|
@@ -132,7 +148,8 @@ function initialize(userOptions: any) {
|
|
|
132
148
|
router.go(relativeHit)
|
|
133
149
|
},
|
|
134
150
|
children
|
|
135
|
-
}
|
|
151
|
+
},
|
|
152
|
+
__v: null
|
|
136
153
|
}
|
|
137
154
|
}
|
|
138
155
|
})
|
|
@@ -11,7 +11,7 @@ export function useNavLink(item) {
|
|
|
11
11
|
active = new RegExp(item.value.activeMatch).test(routePath);
|
|
12
12
|
}
|
|
13
13
|
else {
|
|
14
|
-
const itemPath = normalizePath(
|
|
14
|
+
const itemPath = normalizePath(item.value.link);
|
|
15
15
|
active =
|
|
16
16
|
itemPath === '/'
|
|
17
17
|
? itemPath === routePath
|
|
@@ -55,6 +55,7 @@ li > div[class*='language-'] {
|
|
|
55
55
|
-moz-hyphens: none;
|
|
56
56
|
-ms-hyphens: none;
|
|
57
57
|
hyphens: none;
|
|
58
|
+
background: transparent;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
[class*='language-'] pre {
|
|
@@ -62,7 +63,6 @@ li > div[class*='language-'] {
|
|
|
62
63
|
z-index: 1;
|
|
63
64
|
margin: 0;
|
|
64
65
|
padding: 1.25rem 1.5rem;
|
|
65
|
-
background: transparent;
|
|
66
66
|
overflow-x: auto;
|
|
67
67
|
}
|
|
68
68
|
|
package/dist/node/cli.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var serve = require('./serve-
|
|
3
|
+
var serve = require('./serve-f83deb60.js');
|
|
4
|
+
require('fs');
|
|
5
|
+
require('path');
|
|
6
|
+
require('url');
|
|
4
7
|
require('vite');
|
|
5
8
|
require('readline');
|
|
6
9
|
require('assert');
|
|
@@ -8,12 +11,8 @@ require('events');
|
|
|
8
11
|
require('stream');
|
|
9
12
|
require('util');
|
|
10
13
|
require('buffer');
|
|
11
|
-
require('path');
|
|
12
|
-
require('fs');
|
|
13
14
|
require('punycode');
|
|
14
15
|
require('prismjs');
|
|
15
|
-
require('url');
|
|
16
|
-
require('@vitejs/plugin-vue');
|
|
17
16
|
require('querystring');
|
|
18
17
|
require('tty');
|
|
19
18
|
require('net');
|
|
@@ -275,7 +274,10 @@ if (root) {
|
|
|
275
274
|
argv.root = root;
|
|
276
275
|
}
|
|
277
276
|
if (!command || command === "dev") {
|
|
278
|
-
serve.createServer(root, argv).then((server) => server.listen()).
|
|
277
|
+
serve.createServer(root, argv).then((server) => server.listen()).then((server) => {
|
|
278
|
+
console.log();
|
|
279
|
+
server.printUrls();
|
|
280
|
+
}).catch((err) => {
|
|
279
281
|
console.error(serve.source.red(`failed to start server. error:
|
|
280
282
|
`), err);
|
|
281
283
|
process.exit(1);
|
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-f83deb60.js');
|
|
6
6
|
require('vite');
|
|
7
7
|
require('readline');
|
|
8
8
|
require('assert');
|
|
@@ -15,7 +15,6 @@ require('fs');
|
|
|
15
15
|
require('punycode');
|
|
16
16
|
require('prismjs');
|
|
17
17
|
require('url');
|
|
18
|
-
require('@vitejs/plugin-vue');
|
|
19
18
|
require('querystring');
|
|
20
19
|
require('tty');
|
|
21
20
|
require('net');
|
|
@@ -27,9 +26,10 @@ require('http');
|
|
|
27
26
|
|
|
28
27
|
|
|
29
28
|
exports.build = serve.build;
|
|
29
|
+
exports.createMarkdownRenderer = serve.createMarkdownRenderer;
|
|
30
30
|
exports.createServer = serve.createServer;
|
|
31
|
+
exports.defineConfig = serve.defineConfig;
|
|
31
32
|
exports.resolveConfig = serve.resolveConfig;
|
|
32
33
|
exports.resolveSiteData = serve.resolveSiteData;
|
|
33
34
|
exports.resolveSiteDataByRoute = serve.resolveSiteDataByRoute;
|
|
34
|
-
exports.resolveUserConfig = serve.resolveUserConfig;
|
|
35
35
|
exports.serve = serve.serve;
|