vitepress 1.3.3 → 1.4.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/dist/client/app/components/Content.js +3 -2
- package/dist/client/app/router.js +1 -0
- package/dist/client/index.d.ts +9 -5
- package/dist/client/theme-default/components/VPButton.vue +1 -1
- package/dist/client/theme-default/components/VPFlyout.vue +6 -6
- package/dist/client/theme-default/composables/outline.js +28 -26
- package/dist/client/theme-default/styles/fonts.css +1 -5
- package/dist/client/theme-default/without-fonts.js +3 -0
- package/dist/node/cli.js +228 -217
- package/dist/node/index.d.ts +24 -7
- package/dist/node/index.js +9 -87
- package/dist/node/{serve-lJPQ9bCN.js → serve-Bvg4Nr_L.js} +28130 -26345
- package/package.json +40 -39
- package/template/.vitepress/theme/style.css +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h } from 'vue';
|
|
1
|
+
import { defineComponent, h, watch } from 'vue';
|
|
2
2
|
import { useData, useRoute } from 'vitepress';
|
|
3
3
|
import { contentUpdatedCallbacks } from '../utils';
|
|
4
4
|
const runCbs = () => contentUpdatedCallbacks.forEach((fn) => fn());
|
|
@@ -9,7 +9,8 @@ export const Content = defineComponent({
|
|
|
9
9
|
},
|
|
10
10
|
setup(props) {
|
|
11
11
|
const route = useRoute();
|
|
12
|
-
const { site } = useData();
|
|
12
|
+
const { frontmatter, site } = useData();
|
|
13
|
+
watch(frontmatter, runCbs, { deep: true, flush: 'post' });
|
|
13
14
|
return () => h(props.as, site.value.contentProps ?? { style: { position: 'relative' } }, [
|
|
14
15
|
route.component
|
|
15
16
|
? h(route.component, {
|
|
@@ -46,6 +46,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
46
46
|
if (!comp) {
|
|
47
47
|
throw new Error(`Invalid route component: ${comp}`);
|
|
48
48
|
}
|
|
49
|
+
await router.onAfterPageLoad?.(href);
|
|
49
50
|
route.path = inBrowser ? pendingPath : withBase(pendingPath);
|
|
50
51
|
route.component = markRaw(comp);
|
|
51
52
|
route.data = import.meta.env.PROD
|
package/dist/client/index.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ interface Router {
|
|
|
32
32
|
* updated). Return `false` to cancel the navigation.
|
|
33
33
|
*/
|
|
34
34
|
onBeforePageLoad?: (to: string) => Awaitable<void | boolean>;
|
|
35
|
+
/**
|
|
36
|
+
* Called after the page component is loaded (before the page component is updated).
|
|
37
|
+
*/
|
|
38
|
+
onAfterPageLoad?: (to: string) => Awaitable<void>;
|
|
35
39
|
/**
|
|
36
40
|
* Called after the route changes.
|
|
37
41
|
*/
|
|
@@ -110,20 +114,20 @@ declare function defineClientComponent(loader: AsyncComponentLoader, args?: any[
|
|
|
110
114
|
};
|
|
111
115
|
declare function getScrollOffset(): number;
|
|
112
116
|
|
|
113
|
-
declare const Content: vue.DefineComponent<{
|
|
117
|
+
declare const Content: vue.DefineComponent<vue.ExtractPropTypes<{
|
|
114
118
|
as: {
|
|
115
119
|
type: (ObjectConstructor | StringConstructor)[];
|
|
116
120
|
default: string;
|
|
117
121
|
};
|
|
118
|
-
}
|
|
122
|
+
}>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
|
|
119
123
|
[key: string]: any;
|
|
120
|
-
}>,
|
|
124
|
+
}>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
|
|
121
125
|
as: {
|
|
122
126
|
type: (ObjectConstructor | StringConstructor)[];
|
|
123
127
|
default: string;
|
|
124
128
|
};
|
|
125
|
-
}
|
|
129
|
+
}>> & Readonly<{}>, {
|
|
126
130
|
as: string | Record<string, any>;
|
|
127
|
-
}, {}>;
|
|
131
|
+
}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
|
|
128
132
|
|
|
129
133
|
export { Content, type EnhanceAppContext, type Route, type Router, type Theme, type VitePressData, escapeHtml as _escapeHtml, dataSymbol, defineClientComponent, getScrollOffset, inBrowser, onContentUpdated, useData, useRoute, useRouter, withBase };
|
|
@@ -78,6 +78,12 @@ function onBlur() {
|
|
|
78
78
|
color: var(--vp-c-brand-2);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
+
.button[aria-expanded="false"] + .menu {
|
|
82
|
+
opacity: 0;
|
|
83
|
+
visibility: hidden;
|
|
84
|
+
transform: translateY(0);
|
|
85
|
+
}
|
|
86
|
+
|
|
81
87
|
.VPFlyout:hover .menu,
|
|
82
88
|
.button[aria-expanded="true"] + .menu {
|
|
83
89
|
opacity: 1;
|
|
@@ -85,12 +91,6 @@ function onBlur() {
|
|
|
85
91
|
transform: translateY(0);
|
|
86
92
|
}
|
|
87
93
|
|
|
88
|
-
.button[aria-expanded="false"] + .menu {
|
|
89
|
-
opacity: 0;
|
|
90
|
-
visibility: hidden;
|
|
91
|
-
transform: translateY(0);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
94
|
.button {
|
|
95
95
|
display: flex;
|
|
96
96
|
align-items: center;
|
|
@@ -56,32 +56,7 @@ export function resolveHeaders(headers, range) {
|
|
|
56
56
|
: levelsRange === 'deep'
|
|
57
57
|
? [2, 6]
|
|
58
58
|
: levelsRange;
|
|
59
|
-
|
|
60
|
-
// clear previous caches
|
|
61
|
-
resolvedHeaders.length = 0;
|
|
62
|
-
// update global header list for active link rendering
|
|
63
|
-
for (const { element, link } of headers) {
|
|
64
|
-
resolvedHeaders.push({ element, link });
|
|
65
|
-
}
|
|
66
|
-
const ret = [];
|
|
67
|
-
outer: for (let i = 0; i < headers.length; i++) {
|
|
68
|
-
const cur = headers[i];
|
|
69
|
-
if (i === 0) {
|
|
70
|
-
ret.push(cur);
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
for (let j = i - 1; j >= 0; j--) {
|
|
74
|
-
const prev = headers[j];
|
|
75
|
-
if (prev.level < cur.level) {
|
|
76
|
-
;
|
|
77
|
-
(prev.children || (prev.children = [])).push(cur);
|
|
78
|
-
continue outer;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
ret.push(cur);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return ret;
|
|
59
|
+
return buildTree(headers, high, low);
|
|
85
60
|
}
|
|
86
61
|
export function useActiveAnchor(container, marker) {
|
|
87
62
|
const { isAsideEnabled } = useAside();
|
|
@@ -176,3 +151,30 @@ function getAbsoluteTop(element) {
|
|
|
176
151
|
}
|
|
177
152
|
return offsetTop;
|
|
178
153
|
}
|
|
154
|
+
function buildTree(data, min, max) {
|
|
155
|
+
resolvedHeaders.length = 0;
|
|
156
|
+
const result = [];
|
|
157
|
+
const stack = [];
|
|
158
|
+
data.forEach((item) => {
|
|
159
|
+
const node = { ...item, children: [] };
|
|
160
|
+
let parent = stack[stack.length - 1];
|
|
161
|
+
while (parent && parent.level >= node.level) {
|
|
162
|
+
stack.pop();
|
|
163
|
+
parent = stack[stack.length - 1];
|
|
164
|
+
}
|
|
165
|
+
if (node.element.classList.contains('ignore-header') ||
|
|
166
|
+
(parent && 'shouldIgnore' in parent)) {
|
|
167
|
+
stack.push({ level: node.level, shouldIgnore: true });
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (node.level > max || node.level < min)
|
|
171
|
+
return;
|
|
172
|
+
resolvedHeaders.push({ element: node.element, link: node.link });
|
|
173
|
+
if (parent)
|
|
174
|
+
parent.children.push(node);
|
|
175
|
+
else
|
|
176
|
+
result.push(node);
|
|
177
|
+
stack.push(node);
|
|
178
|
+
});
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
/* webfont-marker-begin */
|
|
2
|
-
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');
|
|
3
|
-
|
|
4
|
-
html body {
|
|
5
|
-
font-synthesis: style;
|
|
6
|
-
}
|
|
2
|
+
@import url('https://fonts.googleapis.com/css2?family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&display=swap');
|
|
7
3
|
/* webfont-marker-end */
|
|
8
4
|
|
|
9
5
|
@font-face {
|
|
@@ -16,7 +16,10 @@ export { default as VPHomeContent } from './components/VPHomeContent.vue';
|
|
|
16
16
|
export { default as VPHomeHero } from './components/VPHomeHero.vue';
|
|
17
17
|
export { default as VPHomeFeatures } from './components/VPHomeFeatures.vue';
|
|
18
18
|
export { default as VPHomeSponsors } from './components/VPHomeSponsors.vue';
|
|
19
|
+
export { default as VPLink } from './components/VPLink.vue';
|
|
19
20
|
export { default as VPDocAsideSponsors } from './components/VPDocAsideSponsors.vue';
|
|
21
|
+
export { default as VPSocialLink } from './components/VPSocialLink.vue';
|
|
22
|
+
export { default as VPSocialLinks } from './components/VPSocialLinks.vue';
|
|
20
23
|
export { default as VPSponsors } from './components/VPSponsors.vue';
|
|
21
24
|
export { default as VPTeamPage } from './components/VPTeamPage.vue';
|
|
22
25
|
export { default as VPTeamPageTitle } from './components/VPTeamPageTitle.vue';
|