diff --git a/src/components/Header.astro b/src/components/Header.astro index f1a60a6..a7b9305 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,48 +1,18 @@ --- import { ThemeSelect } from "@components/hooks/ThemeSwitch"; -import { getTypeData } from "@config/io/generateTypeData"; +import type { TypeData } from "@config/io/types"; import Nav from "@components/navigation/sidebars/nav/index.astro"; import TOC from "@components/navigation/sidebars/TOC.astro"; -import type { TypeTOC } from "./navigation/sidebars/types"; +import type { ConfigHeading } from "@components/navigation/sidebars/types"; import Search from "./navigation/Search.astro"; -const routes = await getTypeData(); - -const url = Astro.url.pathname.split("/"); -const currentClass = url[4]; -const currentData = routes.find( - item => item.name === currentClass -); - -const data = currentData?.data; -const tocFunctions = - data?.functions?.map(item => item.name) || null; - -const propsKeys = data?.properties - ? Object.keys(data.properties) - : null; -const signalKeys = data?.signals - ? Object.keys(data.signals) - : null; -const variantKeys = data?.variants - ? Object.keys(data.variants) - : null; - -let sidebarData: TypeTOC | undefined = { - properties: propsKeys, - functions: tocFunctions, - signals: signalKeys, - variants: variantKeys, -}; - -if (!data) { - sidebarData = undefined; +interface Props { + title?: string; + headings?: ConfigHeading[]; + type?: TypeData; } -const { - title = null, - headings = [], -} = Astro.props; +const { title, headings, type } = Astro.props; ---
@@ -54,6 +24,6 @@ const {
- +
diff --git a/src/components/navigation/sidebars/TOC.astro b/src/components/navigation/sidebars/TOC.astro index 7933715..1effd82 100644 --- a/src/components/navigation/sidebars/TOC.astro +++ b/src/components/navigation/sidebars/TOC.astro @@ -1,15 +1,23 @@ --- import TableOfContents from "./toc"; import type { ConfigHeading, TypeTOC } from "./types.d.ts"; +import type { TypeData } from "@config/io/types"; export interface Props { title?: string; headings?: ConfigHeading[]; - types?: TypeTOC; + type?: TypeData; mobile: boolean; } -const { title, headings, types, mobile } = Astro.props; +const { title, headings, type, mobile } = Astro.props; + +const types: TypeTOC | null = type ? { + properties: Object.keys(type.properties ?? {}), + functions: (type.functions ?? []).map(f => f.name), + signals: Object.keys(type.signals ?? {}), + variants: Object.keys(type.variants ?? {}), +} : null; --- {((headings?.length ?? 0) != 0 || types) &&
diff --git a/src/components/navigation/sidebars/nav/RootNav.astro b/src/components/navigation/sidebars/nav/RootNav.astro index 7a4792d..0b83c24 100644 --- a/src/components/navigation/sidebars/nav/RootNav.astro +++ b/src/components/navigation/sidebars/nav/RootNav.astro @@ -7,15 +7,13 @@ export interface Props { const { currentRoute, currentModule, currentClass } = Astro.props; -import { getTypeData } from "@config/io/generateTypeData"; -import { groupRoutes } from "@config/io/helpers"; +import { getModulesData } from "@config/io/generateTypeData"; import type { TreeEntry } from "./Tree.astro"; import Tree from "./Tree.astro"; import Link from "./Link.astro"; import VersionSelector from "./VersionSelector.astro" -const routes = await getTypeData(); -const groupedRoutes = groupRoutes(routes); +const modules = await getModulesData(); import { getCollection } from "astro:content"; const guidePages = await getCollection("guide"); @@ -45,18 +43,16 @@ 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, - })), - }) - ), + entries: modules.map(module => ({ + title: module.name, + link: `/docs/types/${module.name}`, + current: currentModule === module.name, + entries: module.types.map(type => ({ + title: type.name, + link: `/docs/types/${module.name}/${type.name}`, + current: currentClass === type.name, + })) + })) }; --- diff --git a/src/components/type/Properties.astro b/src/components/type/Properties.astro index 4e50a2f..41e19ca 100644 --- a/src/components/type/Properties.astro +++ b/src/components/type/Properties.astro @@ -4,22 +4,20 @@ import type { QMLTypeLinkObject, QuickshellProps, } from "@config/io/types"; -import { Tag, Flag } from "@icons"; +import { Tag } from "@icons"; import TypeTitle from "./TypeTitle.astro"; import TypeDetails from "./TypeDetails.astro"; export interface Props { - propsKeys: string[]; - propsData: QuickshellProps; + props: QuickshellProps; } -const { propsKeys, propsData } = Astro.props; +const { props } = Astro.props; ---