vitepress 1.4.0 → 1.4.2
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/composables/head.js +1 -1
- package/dist/client/app/data.js +10 -8
- package/dist/client/theme-default/components/VPLocalSearchBox.vue +27 -5
- package/dist/client/theme-default/components/VPMenuLink.vue +12 -3
- package/dist/client/theme-default/components/VPNavBarMenuLink.vue +1 -1
- package/dist/client/theme-default/components/VPNavBarTitle.vue +2 -2
- package/dist/client/theme-default/components/VPNavScreenMenuGroupLink.vue +2 -1
- package/dist/client/theme-default/components/VPNavScreenMenuLink.vue +7 -3
- package/dist/client/theme-default/styles/components/vp-doc.css +1 -0
- package/dist/client/theme-default/styles/vars.css +2 -3
- package/dist/node/cli.js +2 -1
- package/dist/node/index.d.ts +8 -4
- package/dist/node/index.js +3 -4
- package/dist/node/{serve-Bvg4Nr_L.js → serve-BSNQCR34.js} +288 -255
- package/package.json +22 -22
- package/theme.d.ts +3 -0
|
@@ -64,7 +64,7 @@ function createHeadElement([tag, attrs, innerHTML]) {
|
|
|
64
64
|
if (innerHTML) {
|
|
65
65
|
el.innerHTML = innerHTML;
|
|
66
66
|
}
|
|
67
|
-
if (tag === 'script' &&
|
|
67
|
+
if (tag === 'script' && attrs.async == null) {
|
|
68
68
|
// async is true by default for dynamically created scripts
|
|
69
69
|
;
|
|
70
70
|
el.async = false;
|
package/dist/client/app/data.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import siteData from '@siteData';
|
|
2
|
-
import { useDark } from '@vueuse/core';
|
|
2
|
+
import { useDark, usePreferredDark } from '@vueuse/core';
|
|
3
3
|
import { computed, inject, readonly, ref, shallowRef, watch } from 'vue';
|
|
4
4
|
import { APPEARANCE_KEY, createTitle, inBrowser, resolveSiteDataByRoute } from '../shared';
|
|
5
5
|
export const dataSymbol = Symbol();
|
|
@@ -19,13 +19,15 @@ export function initData(route) {
|
|
|
19
19
|
const appearance = site.value.appearance; // fine with reactivity being lost here, config change triggers a restart
|
|
20
20
|
const isDark = appearance === 'force-dark'
|
|
21
21
|
? ref(true)
|
|
22
|
-
: appearance
|
|
23
|
-
?
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
: appearance === 'force-auto'
|
|
23
|
+
? usePreferredDark()
|
|
24
|
+
: appearance
|
|
25
|
+
? useDark({
|
|
26
|
+
storageKey: APPEARANCE_KEY,
|
|
27
|
+
initialValue: () => (appearance === 'dark' ? 'dark' : 'auto'),
|
|
28
|
+
...(typeof appearance === 'object' ? appearance : {})
|
|
29
|
+
})
|
|
30
|
+
: ref(false);
|
|
29
31
|
const hashRef = ref(inBrowser ? location.hash : '');
|
|
30
32
|
if (inBrowser) {
|
|
31
33
|
window.addEventListener('hashchange', () => {
|
|
@@ -281,7 +281,7 @@ function onSearchBarClick(event: PointerEvent) {
|
|
|
281
281
|
/* Search keyboard selection */
|
|
282
282
|
|
|
283
283
|
const selectedIndex = ref(-1)
|
|
284
|
-
const disableMouseOver = ref(
|
|
284
|
+
const disableMouseOver = ref(true)
|
|
285
285
|
|
|
286
286
|
watch(results, (r) => {
|
|
287
287
|
selectedIndex.value = r.length ? 0 : -1
|
|
@@ -400,6 +400,16 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
400
400
|
'gi'
|
|
401
401
|
)
|
|
402
402
|
}
|
|
403
|
+
|
|
404
|
+
function onMouseMove(e: MouseEvent) {
|
|
405
|
+
if (!disableMouseOver.value) return
|
|
406
|
+
const el = (e.target as HTMLElement)?.closest<HTMLAnchorElement>('.result')
|
|
407
|
+
const index = Number.parseInt(el?.dataset.index!)
|
|
408
|
+
if (index >= 0 && index !== selectedIndex.value) {
|
|
409
|
+
selectedIndex.value = index
|
|
410
|
+
}
|
|
411
|
+
disableMouseOver.value = false
|
|
412
|
+
}
|
|
403
413
|
</script>
|
|
404
414
|
|
|
405
415
|
<template>
|
|
@@ -440,10 +450,20 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
440
450
|
<input
|
|
441
451
|
ref="searchInput"
|
|
442
452
|
v-model="filterText"
|
|
443
|
-
:
|
|
444
|
-
|
|
453
|
+
:aria-activedescendant="selectedIndex > -1 ? ('localsearch-item-' + selectedIndex) : undefined"
|
|
454
|
+
aria-autocomplete="both"
|
|
455
|
+
:aria-controls="results?.length ? 'localsearch-list' : undefined"
|
|
445
456
|
aria-labelledby="localsearch-label"
|
|
457
|
+
autocapitalize="off"
|
|
458
|
+
autocomplete="off"
|
|
459
|
+
autocorrect="off"
|
|
446
460
|
class="search-input"
|
|
461
|
+
id="localsearch-input"
|
|
462
|
+
enterkeyhint="go"
|
|
463
|
+
maxlength="64"
|
|
464
|
+
:placeholder="buttonText"
|
|
465
|
+
spellcheck="false"
|
|
466
|
+
type="search"
|
|
447
467
|
/>
|
|
448
468
|
<div class="search-actions">
|
|
449
469
|
<button
|
|
@@ -477,13 +497,14 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
477
497
|
:role="results?.length ? 'listbox' : undefined"
|
|
478
498
|
:aria-labelledby="results?.length ? 'localsearch-label' : undefined"
|
|
479
499
|
class="results"
|
|
480
|
-
@mousemove="
|
|
500
|
+
@mousemove="onMouseMove"
|
|
481
501
|
>
|
|
482
502
|
<li
|
|
483
503
|
v-for="(p, index) in results"
|
|
484
504
|
:key="p.id"
|
|
485
|
-
|
|
505
|
+
:id="'localsearch-item-' + index"
|
|
486
506
|
:aria-selected="selectedIndex === index ? 'true' : 'false'"
|
|
507
|
+
role="option"
|
|
487
508
|
>
|
|
488
509
|
<a
|
|
489
510
|
:href="p.id"
|
|
@@ -495,6 +516,7 @@ function formMarkRegex(terms: Set<string>) {
|
|
|
495
516
|
@mouseenter="!disableMouseOver && (selectedIndex = index)"
|
|
496
517
|
@focusin="selectedIndex = index"
|
|
497
518
|
@click="$emit('close')"
|
|
519
|
+
:data-index="index"
|
|
498
520
|
>
|
|
499
521
|
<div>
|
|
500
522
|
<div class="titles">
|
|
@@ -14,12 +14,19 @@ const { page } = useData()
|
|
|
14
14
|
<template>
|
|
15
15
|
<div class="VPMenuLink">
|
|
16
16
|
<VPLink
|
|
17
|
-
:class="{
|
|
17
|
+
:class="{
|
|
18
|
+
active: isActive(
|
|
19
|
+
page.relativePath,
|
|
20
|
+
item.activeMatch || item.link,
|
|
21
|
+
!!item.activeMatch
|
|
22
|
+
)
|
|
23
|
+
}"
|
|
18
24
|
:href="item.link"
|
|
19
25
|
:target="item.target"
|
|
20
26
|
:rel="item.rel"
|
|
27
|
+
:no-icon="item.noIcon"
|
|
21
28
|
>
|
|
22
|
-
|
|
29
|
+
<span v-html="item.text"></span>
|
|
23
30
|
</VPLink>
|
|
24
31
|
</div>
|
|
25
32
|
</template>
|
|
@@ -40,7 +47,9 @@ const { page } = useData()
|
|
|
40
47
|
font-weight: 500;
|
|
41
48
|
color: var(--vp-c-text-1);
|
|
42
49
|
white-space: nowrap;
|
|
43
|
-
transition:
|
|
50
|
+
transition:
|
|
51
|
+
background-color 0.25s,
|
|
52
|
+
color 0.25s;
|
|
44
53
|
}
|
|
45
54
|
|
|
46
55
|
.link:hover {
|
|
@@ -39,8 +39,8 @@ const target = computed(() =>
|
|
|
39
39
|
>
|
|
40
40
|
<slot name="nav-bar-title-before" />
|
|
41
41
|
<VPImage v-if="theme.logo" class="logo" :image="theme.logo" />
|
|
42
|
-
<
|
|
43
|
-
<
|
|
42
|
+
<span v-if="theme.siteTitle" v-html="theme.siteTitle"></span>
|
|
43
|
+
<span v-else-if="theme.siteTitle === undefined">{{ site.title }}</span>
|
|
44
44
|
<slot name="nav-bar-title-after" />
|
|
45
45
|
</a>
|
|
46
46
|
</div>
|
|
@@ -16,9 +16,10 @@ const closeScreen = inject('close-screen') as () => void
|
|
|
16
16
|
:href="item.link"
|
|
17
17
|
:target="item.target"
|
|
18
18
|
:rel="item.rel"
|
|
19
|
+
:no-icon="item.noIcon"
|
|
19
20
|
@click="closeScreen"
|
|
20
21
|
>
|
|
21
|
-
|
|
22
|
+
<span v-html="item.text"></span>
|
|
22
23
|
</VPLink>
|
|
23
24
|
</template>
|
|
24
25
|
|
|
@@ -16,9 +16,11 @@ const closeScreen = inject('close-screen') as () => void
|
|
|
16
16
|
:href="item.link"
|
|
17
17
|
:target="item.target"
|
|
18
18
|
:rel="item.rel"
|
|
19
|
+
:no-icon="item.noIcon"
|
|
19
20
|
@click="closeScreen"
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
>
|
|
22
|
+
<span v-html="item.text"></span>
|
|
23
|
+
</VPLink>
|
|
22
24
|
</template>
|
|
23
25
|
|
|
24
26
|
<style scoped>
|
|
@@ -30,7 +32,9 @@ const closeScreen = inject('close-screen') as () => void
|
|
|
30
32
|
font-size: 14px;
|
|
31
33
|
font-weight: 500;
|
|
32
34
|
color: var(--vp-c-text-1);
|
|
33
|
-
transition:
|
|
35
|
+
transition:
|
|
36
|
+
border-color 0.25s,
|
|
37
|
+
color 0.25s;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
.VPNavScreenMenuLink:hover {
|
|
@@ -270,9 +270,8 @@
|
|
|
270
270
|
|
|
271
271
|
:root:where(:lang(zh)) {
|
|
272
272
|
--vp-font-family-base: 'Punctuation SC', 'Inter', ui-sans-serif, system-ui,
|
|
273
|
-
|
|
274
|
-
'
|
|
275
|
-
'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji';
|
|
273
|
+
sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol',
|
|
274
|
+
'Noto Color Emoji';
|
|
276
275
|
}
|
|
277
276
|
|
|
278
277
|
/**
|
package/dist/node/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as getDefaultExportFromCjs, u as c, n as disposeMdItInstance, v as clearCache, l as init, b as build, o as serve, w as version, q as createServer } from './serve-BSNQCR34.js';
|
|
2
2
|
import { createLogger } from 'vite';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'shiki';
|
|
@@ -357,6 +357,7 @@ const SHORTCUTS = [
|
|
|
357
357
|
clear: true,
|
|
358
358
|
timestamp: true
|
|
359
359
|
});
|
|
360
|
+
disposeMdItInstance();
|
|
360
361
|
clearCache();
|
|
361
362
|
await server.close();
|
|
362
363
|
await createDevServer();
|
package/dist/node/index.d.ts
CHANGED
|
@@ -2164,7 +2164,7 @@ interface MarkdownOptions extends Options$2 {
|
|
|
2164
2164
|
*/
|
|
2165
2165
|
container?: ContainerOptions;
|
|
2166
2166
|
/**
|
|
2167
|
-
* Math support
|
|
2167
|
+
* Math support
|
|
2168
2168
|
*
|
|
2169
2169
|
* You need to install `markdown-it-mathjax3` and set `math` to `true` to enable it.
|
|
2170
2170
|
* You can also pass options to `markdown-it-mathjax3` here.
|
|
@@ -2181,7 +2181,11 @@ interface MarkdownOptions extends Options$2 {
|
|
|
2181
2181
|
gfmAlerts?: boolean;
|
|
2182
2182
|
}
|
|
2183
2183
|
type MarkdownRenderer = MarkdownIt;
|
|
2184
|
-
declare
|
|
2184
|
+
declare function disposeMdItInstance(): void;
|
|
2185
|
+
/**
|
|
2186
|
+
* @experimental
|
|
2187
|
+
*/
|
|
2188
|
+
declare function createMarkdownRenderer(srcDir: string, options?: MarkdownOptions, base?: string, logger?: Pick<Logger, 'warn'>): Promise<MarkdownRenderer>;
|
|
2185
2189
|
|
|
2186
2190
|
type RawConfigExports<ThemeConfig = any> = Awaitable<UserConfig<ThemeConfig>> | (() => Awaitable<UserConfig<ThemeConfig>>);
|
|
2187
2191
|
interface TransformContext {
|
|
@@ -2304,7 +2308,7 @@ interface UserConfig<ThemeConfig = any> extends LocaleSpecificConfig<ThemeConfig
|
|
|
2304
2308
|
*
|
|
2305
2309
|
* source -> destination
|
|
2306
2310
|
*/
|
|
2307
|
-
rewrites?: Record<string, string
|
|
2311
|
+
rewrites?: Record<string, string> | ((id: string) => string);
|
|
2308
2312
|
/**
|
|
2309
2313
|
* @experimental
|
|
2310
2314
|
*/
|
|
@@ -2608,4 +2612,4 @@ declare function createServer(root?: string, serverOptions?: ServerOptions & {
|
|
|
2608
2612
|
base?: string;
|
|
2609
2613
|
}, recreateServer?: () => Promise<void>): Promise<vite.ViteDevServer>;
|
|
2610
2614
|
|
|
2611
|
-
export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, init, mergeConfig, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
|
|
2615
|
+
export { type ContentData, type ContentOptions, type LoaderModule, type MarkdownOptions, type MarkdownRenderer, type RawConfigExports, type ResolvedRouteConfig, type ScaffoldOptions, ScaffoldThemeType, type ServeOptions, type SiteConfig, type ThemeOptions, type TransformContext, type TransformPageContext, type UserConfig, type UserConfigExport, type UserConfigFn, build, createContentLoader, createMarkdownRenderer, createServer, defineConfig, defineConfigWithTheme, defineLoader, disposeMdItInstance, init, mergeConfig, postcssIsolateStyles, resolveConfig, resolvePages, resolveSiteData, resolveUserConfig, scaffold, serve };
|
package/dist/node/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { normalizePath } from 'vite';
|
|
2
2
|
export { loadEnv } from 'vite';
|
|
3
|
-
import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, p as postcssPrefixSelector } from './serve-
|
|
4
|
-
export { S as ScaffoldThemeType, b as build,
|
|
3
|
+
import { g as glob, c as createMarkdownRenderer, f as fs, m as matter, p as postcssPrefixSelector } from './serve-BSNQCR34.js';
|
|
4
|
+
export { S as ScaffoldThemeType, b as build, q as createServer, a as defineConfig, e as defineConfigWithTheme, d as defineLoader, n as disposeMdItInstance, l as init, i as mergeConfig, r as resolveConfig, k as resolvePages, j as resolveSiteData, h as resolveUserConfig, s as scaffold, o as serve } from './serve-BSNQCR34.js';
|
|
5
5
|
import path from 'path';
|
|
6
6
|
import 'crypto';
|
|
7
7
|
import 'module';
|
|
@@ -52,7 +52,6 @@ function createContentLoader(pattern, {
|
|
|
52
52
|
}
|
|
53
53
|
if (typeof pattern === "string") pattern = [pattern];
|
|
54
54
|
pattern = pattern.map((p) => normalizePath(path.join(config.srcDir, p)));
|
|
55
|
-
let md;
|
|
56
55
|
const cache = /* @__PURE__ */ new Map();
|
|
57
56
|
return {
|
|
58
57
|
watch: pattern,
|
|
@@ -64,7 +63,7 @@ function createContentLoader(pattern, {
|
|
|
64
63
|
...globOptions
|
|
65
64
|
})).sort();
|
|
66
65
|
}
|
|
67
|
-
md =
|
|
66
|
+
const md = await createMarkdownRenderer(
|
|
68
67
|
config.srcDir,
|
|
69
68
|
config.markdown,
|
|
70
69
|
config.site.base,
|