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.
@@ -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 }, document.title);
27
- history.pushState(null, '', href);
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(null, '', href);
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(null, '', href);
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-Csn-CKFx.js';
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';