aboutsummaryrefslogtreecommitdiff
path: root/website/src/components/Sidebar.astro
diff options
context:
space:
mode:
authorOgulcan Celik <ogulcancelik@gmail.com>2026-09-01 14:48:45 +0300
committerOgulcan Celik <ogulcancelik@gmail.com>2026-09-01 14:48:45 +0300
commit8a6d697308162874a236c84aac0b0f8c7ac01f83 (patch)
treeed7dc7e8c6f50d66bde721fae78576aede929f66 /website/src/components/Sidebar.astro
parentb54a78aa510b87d1e3b56c619b72eaeb59e4a2a1 (diff)
refactor: separate website presentation from runtime
Diffstat (limited to 'website/src/components/Sidebar.astro')
-rw-r--r--website/src/components/Sidebar.astro53
1 files changed, 0 insertions, 53 deletions
diff --git a/website/src/components/Sidebar.astro b/website/src/components/Sidebar.astro
deleted file mode 100644
index 08d31f79..00000000
--- a/website/src/components/Sidebar.astro
+++ /dev/null
@@ -1,53 +0,0 @@
----
-import MobileMenuFooter from 'virtual:starlight/components/MobileMenuFooter';
-import SidebarPersister from '@astrojs/starlight/components/SidebarPersister.astro';
-import SidebarSublist from '@astrojs/starlight/components/SidebarSublist.astro';
-import versions from '../data/docs-versions.json';
-import { docsRoute, docsTargetHref } from '../docs-path';
-
-const { sidebar } = Astro.locals.starlightRoute;
-const pathname = Astro.url.pathname;
-const route = docsRoute(pathname);
-const scopedSidebar = route.target === 'stable' ? sidebar : rewriteSidebar(sidebar);
-
-function rewriteSidebar(entries) {
- return entries.flatMap((entry) => {
- if (entry.type === 'link') {
- const linkRoute = docsRoute(entry.href);
- if (!linkRoute.isDocs) return [entry];
- if (linkRoute.target !== 'stable') {
- return linkRoute.target === route.target
- ? [{ ...entry, isCurrent: samePath(entry.href, pathname) }]
- : [];
- }
-
- const localeKey = route.locale ?? 'root';
- const availablePages = versions.scopes[route.target]?.locales[localeKey] ?? [];
- if (!availablePages.includes(linkRoute.page)) return [];
-
- const href = docsTargetHref({ ...linkRoute, locale: route.locale }, route.target, versions.scopes);
- return [{ ...entry, href, isCurrent: samePath(href, pathname) }];
- }
-
- const rewrittenEntries = rewriteSidebar(entry.entries);
- if (rewrittenEntries.length === 0) return [];
- return [{ ...entry, entries: rewrittenEntries }];
- });
-}
-
-function samePath(left, right) {
- return stripTrailingSlash(left) === stripTrailingSlash(right);
-}
-
-function stripTrailingSlash(path) {
- return path.length > 1 ? path.replace(/\/$/, '') : path;
-}
----
-
-<SidebarPersister>
- <SidebarSublist sublist={scopedSidebar} />
-</SidebarPersister>
-
-<div class="md:sl-hidden">
- <MobileMenuFooter />
-</div>