Skip to content

Commit

Permalink
Refactor SingleSidebar.astro: Update sidebar links logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Adammatthiesen committed Dec 17, 2024
1 parent e52edcf commit 52b5782
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions packages/studiocms_dashboard/src/components/SingleSidebar.astro
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ const t = useTranslations(lang, '@studiocms/dashboard:sidebar');
import { SingleSidebarHelper } from "@studiocms/ui/components";
import { DropdownHelper } from "@studiocms/ui/components";

document.addEventListener('astro:page-load', () => {
new SingleSidebarHelper('nav-toggle');
new DropdownHelper('sidebar-user-dropdown', true);
function sidebarLinks() {
const sidebar = document.querySelector<HTMLElement>('.sidebar')!;
const sidebarLinks = sidebar.querySelectorAll<HTMLAnchorElement>('a');

Expand All @@ -64,6 +62,14 @@ const t = useTranslations(lang, '@studiocms/dashboard:sidebar');
link.classList.add('active');
}
}
}

sidebarLinks();

document.addEventListener('astro:page-load', () => {
new SingleSidebarHelper('nav-toggle');
new DropdownHelper('sidebar-user-dropdown', true);
sidebarLinks();
});
</script>
<style>
Expand Down

0 comments on commit 52b5782

Please sign in to comment.