vitepress 1.1.0 → 1.1.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/router.js +10 -4
- package/dist/node/cli.js +1 -1
- package/dist/node/index.d.ts +311 -317
- package/dist/node/index.js +2 -2
- package/dist/node/{serve-Csn-CKFx.js → serve-DZ7Ijn1Q.js} +213 -127
- package/package.json +56 -57
- package/types/default-theme.d.ts +2 -2
|
@@ -23,8 +23,8 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
23
23
|
return;
|
|
24
24
|
if (inBrowser && href !== normalizeHref(location.href)) {
|
|
25
25
|
// save scroll position before changing url
|
|
26
|
-
history.replaceState({ scrollPosition: window.scrollY },
|
|
27
|
-
history.pushState(
|
|
26
|
+
history.replaceState({ scrollPosition: window.scrollY }, '');
|
|
27
|
+
history.pushState({}, '', href);
|
|
28
28
|
}
|
|
29
29
|
await loadPage(href);
|
|
30
30
|
await router.onAfterRouteChanged?.(href);
|
|
@@ -61,7 +61,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
61
61
|
if (actualPathname !== targetLoc.pathname) {
|
|
62
62
|
targetLoc.pathname = actualPathname;
|
|
63
63
|
href = actualPathname + targetLoc.search + targetLoc.hash;
|
|
64
|
-
history.replaceState(
|
|
64
|
+
history.replaceState({}, '', href);
|
|
65
65
|
}
|
|
66
66
|
if (targetLoc.hash && !scrollPosition) {
|
|
67
67
|
let target = null;
|
|
@@ -107,6 +107,9 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
if (inBrowser) {
|
|
110
|
+
if (history.state === null) {
|
|
111
|
+
history.replaceState({}, '');
|
|
112
|
+
}
|
|
110
113
|
window.addEventListener('click', (e) => {
|
|
111
114
|
// temporary fix for docsearch action buttons
|
|
112
115
|
const button = e.target.closest('button');
|
|
@@ -135,7 +138,7 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
135
138
|
// scroll between hash anchors in the same page
|
|
136
139
|
// avoid duplicate history entries when the hash is same
|
|
137
140
|
if (hash !== currentUrl.hash) {
|
|
138
|
-
history.pushState(
|
|
141
|
+
history.pushState({}, '', href);
|
|
139
142
|
// still emit the event so we can listen to it in themes
|
|
140
143
|
window.dispatchEvent(new HashChangeEvent('hashchange', {
|
|
141
144
|
oldURL: currentUrl.href,
|
|
@@ -157,6 +160,9 @@ export function createRouter(loadPageModule, fallbackComponent) {
|
|
|
157
160
|
}
|
|
158
161
|
}, { capture: true });
|
|
159
162
|
window.addEventListener('popstate', async (e) => {
|
|
163
|
+
if (e.state === null) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
160
166
|
await loadPage(normalizeHref(location.href), (e.state && e.state.scrollPosition) || 0);
|
|
161
167
|
router.onAfterRouteChanged?.(location.href);
|
|
162
168
|
});
|
package/dist/node/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as getDefaultExportFromCjs, q as c, t as clearCache, n as init, b as build, o as serve, v as version, p as createServer } from './serve-
|
|
1
|
+
import { a as getDefaultExportFromCjs, q as c, t as clearCache, n as init, b as build, o as serve, v as version, p as createServer } from './serve-DZ7Ijn1Q.js';
|
|
2
2
|
import { createLogger } from 'vite';
|
|
3
3
|
import 'path';
|
|
4
4
|
import 'url';
|