|
1 | 1 | --- |
2 | | -import MobileMenuFooter from "@astrojs/starlight/components/MobileMenuFooter.astro"; |
3 | | -import SidebarPersister from "@astrojs/starlight/components/SidebarPersister.astro"; |
4 | | -import SidebarSublist from "@astrojs/starlight/components/SidebarSublist.astro"; |
| 2 | +import MobileMenuFooter from '@astrojs/starlight/components/MobileMenuFooter.astro'; |
| 3 | +import SidebarPersister from '@astrojs/starlight/components/SidebarPersister.astro'; |
| 4 | +import SidebarSublist from '@astrojs/starlight/components/SidebarSublist.astro'; |
| 5 | +import StarlightSidebarTopicsSidebar from 'starlight-sidebar-topics/components/Sidebar.astro'; |
5 | 6 |
|
6 | 7 | const { sidebar } = Astro.locals.starlightRoute; |
7 | 8 | --- |
8 | 9 |
|
9 | 10 | <script is:inline aria-hidden="true"> |
10 | | - // This script scrolls the sidebar to the link matching the current page when the page loads |
11 | | - window.addEventListener("load", () => { |
12 | | - const sidebarContainer = document.getElementById("starlight__sidebar"); |
13 | | - const currentItem = sidebarContainer.querySelector( |
14 | | - "a[aria-current='page']" |
15 | | - ); |
16 | | - if (currentItem) { |
17 | | - sidebarContainer.scrollTo({ |
18 | | - top: currentItem.offsetTop - sidebarContainer.offsetTop, |
19 | | - behavior: "smooth", |
20 | | - }); |
21 | | - } |
22 | | - }); |
| 11 | + // This script scrolls the sidebar to the link matching the current page when the page loads |
| 12 | + window.addEventListener('load', () => { |
| 13 | + const sidebarContainer = document.getElementById('starlight__sidebar'); |
| 14 | + const currentItem = sidebarContainer.querySelector( |
| 15 | + "a[aria-current='page']" |
| 16 | + ); |
| 17 | + if (currentItem) { |
| 18 | + sidebarContainer.scrollTo({ |
| 19 | + top: currentItem.offsetTop - sidebarContainer.offsetTop, |
| 20 | + behavior: 'smooth', |
| 21 | + }); |
| 22 | + } |
| 23 | + }); |
23 | 24 | </script> |
24 | 25 |
|
| 26 | +<StarlightSidebarTopicsSidebar /> |
| 27 | + |
25 | 28 | <SidebarPersister> |
26 | | - <SidebarSublist sublist={sidebar} /> |
| 29 | + <SidebarSublist sublist={sidebar} /> |
27 | 30 | </SidebarPersister> |
28 | 31 |
|
29 | 32 | <div class="md:sl-hidden"> |
30 | | - <MobileMenuFooter /> |
| 33 | + <MobileMenuFooter /> |
31 | 34 | </div> |
0 commit comments