vitepress 2.0.0-alpha.6 → 2.0.0-alpha.7
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 +9 -4
- package/dist/client/index.d.ts +1 -0
- package/dist/node/{chunk-cyL7XSn2.js → chunk-CWIFpuXB.js} +1135 -1221
- package/dist/node/cli.js +1 -1
- package/dist/node/index.d.ts +24 -30
- package/dist/node/index.js +24 -36
- package/package.json +26 -26
|
@@ -222,7 +222,7 @@ function normalizeHref(href) {
|
|
|
222
222
|
}
|
|
223
223
|
return url.pathname + url.search + url.hash;
|
|
224
224
|
}
|
|
225
|
-
async function changeRoute(href, { smoothScroll = false, initialLoad = false } = {}) {
|
|
225
|
+
async function changeRoute(href, { smoothScroll = false, initialLoad = false, replace = false } = {}) {
|
|
226
226
|
const loc = normalizeHref(location.href);
|
|
227
227
|
const nextUrl = new URL(href, location.origin);
|
|
228
228
|
const currentUrl = new URL(loc, location.origin);
|
|
@@ -233,9 +233,14 @@ async function changeRoute(href, { smoothScroll = false, initialLoad = false } =
|
|
|
233
233
|
}
|
|
234
234
|
}
|
|
235
235
|
else {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
236
|
+
if (replace) {
|
|
237
|
+
history.replaceState({}, '', href);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
// save scroll position before changing URL
|
|
241
|
+
history.replaceState({ scrollPosition: window.scrollY }, '');
|
|
242
|
+
history.pushState({}, '', href);
|
|
243
|
+
}
|
|
239
244
|
if (nextUrl.pathname === currentUrl.pathname) {
|
|
240
245
|
// scroll between hash anchors on the same page, avoid duplicate entries
|
|
241
246
|
if (nextUrl.hash !== currentUrl.hash) {
|
package/dist/client/index.d.ts
CHANGED