forked from HyperZoneLogin/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSidebar.astro
More file actions
47 lines (39 loc) · 1.4 KB
/
Copy pathSidebar.astro
File metadata and controls
47 lines (39 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
---
import MobileMenuFooter from "virtual:starlight/components/MobileMenuFooter";
import SidebarPersister from "@astrojs/starlight/components/SidebarPersister.astro";
import SidebarSublist from "@astrojs/starlight/components/SidebarSublist.astro";
const { sidebar } = Astro.locals.starlightRoute;
const currentPath = Astro.url.pathname;
const activeGroupKey = currentPath.startsWith("/manual/en/")
? "en"
: currentPath.startsWith("/manual/ru/")
? "ru"
: currentPath.startsWith("/manual/zh/") || currentPath.startsWith("/用户手册/")
? "zh"
: currentPath.startsWith("/developer/")
? "developer"
: "navigation";
const groupLabelsByKey: Record<string, string[]> = {
navigation: ["Navigation"],
en: ["User Manual (EN)"],
ru: ["Руководство пользователя (RU)", "User Manual (RU)"],
zh: ["用户手册 (ZH)", "User Manual (ZH)"],
developer: ["Developer Docs"],
};
const filteredSidebar = sidebar.filter((entry) => {
if (entry.type !== "group") {
return false;
}
return groupLabelsByKey[activeGroupKey]?.includes(entry.label) ?? false;
});
const sidebarToRender =
filteredSidebar.length > 0
? filteredSidebar
: sidebar.filter((entry) => entry.type === "group" && entry.label === "Navigation");
---
<SidebarPersister>
<SidebarSublist sublist={sidebarToRender} />
</SidebarPersister>
<div class="md:sl-hidden">
<MobileMenuFooter />
</div>