79 lines
2 KiB
Text
79 lines
2 KiB
Text
---
|
|
export interface Props {
|
|
currentRoute?: string;
|
|
currentModule?: string;
|
|
currentClass?: string;
|
|
}
|
|
|
|
const { currentRoute, currentModule, currentClass } = Astro.props;
|
|
|
|
import { getTypeData } from "@config/io/generateTypeData";
|
|
import { groupRoutes } from "@config/io/helpers";
|
|
import type { TreeEntry } from "./Tree.astro";
|
|
import Tree from "./Tree.astro";
|
|
import Link from "./Link.astro";
|
|
|
|
const routes = await getTypeData();
|
|
const groupedRoutes = groupRoutes(routes);
|
|
|
|
import { getCollection } from "astro:content";
|
|
const guidePages = await getCollection("guide");
|
|
|
|
function genGuideNav(base: string): TreeEntry[] | undefined {
|
|
const pages = guidePages
|
|
.filter(page => page.id.match(`^${base}[^/]*$`) !== null && page.id != "index")
|
|
.sort((a, b) => a.data.index - b.data.index)
|
|
.map(page => ({
|
|
title: page.data.title,
|
|
link: `/docs/guide/${page.id}`,
|
|
current: currentModule === page.id,
|
|
entries: genGuideNav(page.id + "/"),
|
|
}));
|
|
|
|
return pages.length == 0 ? undefined : pages;
|
|
}
|
|
|
|
const guide = {
|
|
title: "Usage Guide",
|
|
link: "/docs/guide",
|
|
current: currentRoute?.startsWith("guide") ?? false,
|
|
entries: genGuideNav(""),
|
|
}
|
|
|
|
const types = {
|
|
title: "Quickshell Types",
|
|
link: "/docs/types",
|
|
current: currentRoute?.startsWith("types") ?? false,
|
|
entries: Object.entries(groupedRoutes.types).map(
|
|
([module, items]) => ({
|
|
title: module,
|
|
link: `/docs/types/${module}`,
|
|
current: currentModule === module,
|
|
entries: items.map(type => ({
|
|
title: type.name,
|
|
link: `/docs/types/${module}/${type.name}`,
|
|
current: currentClass === type.name,
|
|
})),
|
|
})
|
|
),
|
|
};
|
|
---
|
|
<nav class="navtree">
|
|
<Link
|
|
title="About Quickshell"
|
|
link="/docs/about"
|
|
current={currentRoute === "about"}
|
|
/>
|
|
<Tree {...guide}/>
|
|
<Tree {...types}/>
|
|
<Link
|
|
title="QtQuick Types"
|
|
link="https://doc.qt.io/qt-6/qtquick-qmlmodule.html"
|
|
showIcon={true}
|
|
/>
|
|
<Link
|
|
title="Quickshell Examples"
|
|
link="https://git.outfoxxed.me/outfoxxed/quickshell-examples"
|
|
showIcon={true}
|
|
/>
|
|
</nav>
|