@astrojs/starlight 0.26.0 → 0.26.1
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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @astrojs/starlight
|
|
2
2
|
|
|
3
|
+
## 0.26.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#2219](https://github.com/withastro/starlight/pull/2219) [`74d4716`](https://github.com/withastro/starlight/commit/74d4716f6a70fbef486e1057b81d2280c40251df) Thanks [@HiDeoo](https://github.com/HiDeoo)! - Fixes a sidebar persistence issue when navigating between pages with different sidebar content.
|
|
8
|
+
|
|
3
9
|
## 0.26.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -16,17 +16,19 @@ interface SidebarState {
|
|
|
16
16
|
/**
|
|
17
17
|
* Get the current sidebar state.
|
|
18
18
|
*
|
|
19
|
-
* The `open` state is loaded from session storage, while `scroll`
|
|
19
|
+
* The `open` state is loaded from session storage when the sidebar hashes match, while `scroll`
|
|
20
|
+
* and `hash` are read from the current page.
|
|
20
21
|
*/
|
|
21
22
|
const getState = (): SidebarState => {
|
|
22
23
|
let open = [];
|
|
24
|
+
const hash = target?.dataset.hash || '';
|
|
23
25
|
try {
|
|
24
26
|
const rawStoredState = sessionStorage.getItem(storageKey);
|
|
25
27
|
const storedState = JSON.parse(rawStoredState || '{}');
|
|
26
|
-
if (Array.isArray(storedState.open)) open = storedState.open;
|
|
28
|
+
if (Array.isArray(storedState.open) && storedState.hash === hash) open = storedState.open;
|
|
27
29
|
} catch {}
|
|
28
30
|
return {
|
|
29
|
-
hash
|
|
31
|
+
hash,
|
|
30
32
|
open,
|
|
31
33
|
scroll: scroller?.scrollTop || 0,
|
|
32
34
|
};
|