diff --git a/apps/docs/src/lib/components/Sidebar.svelte b/apps/docs/src/lib/components/Sidebar.svelte index bc20dbb5..343a7b2f 100644 --- a/apps/docs/src/lib/components/Sidebar.svelte +++ b/apps/docs/src/lib/components/Sidebar.svelte @@ -22,6 +22,20 @@ } from 'radix-icons-svelte'; import { base } from '$app/paths'; + export let pathname: string; + + let accordionEl: HTMLElement; + $: { + // Sets the active link in the Sidebar when the page changes + accordionEl?.querySelectorAll('a').forEach((a) => { + if (a.getAttribute('href') === pathname) { + a.classList.add('active'); + } else { + a.classList.remove('active'); + } + }); + } + const useStyles = createStyles(() => ({ '.svelteui-AccordionItem-panel': { padding: '0 !important', @@ -76,7 +90,13 @@