diff --git a/docs/public/burger.svg b/docs/public/burger.svg new file mode 100644 index 0000000..545f9e2 --- /dev/null +++ b/docs/public/burger.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/public/cross.svg b/docs/public/cross.svg new file mode 100644 index 0000000..280c4d0 --- /dev/null +++ b/docs/public/cross.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/docs/src/components/DocsHeader.astro b/docs/src/components/DocsHeader.astro deleted file mode 100644 index 63a5436..0000000 --- a/docs/src/components/DocsHeader.astro +++ /dev/null @@ -1,13 +0,0 @@ ---- -import { getFormattedStars } from "../lib/github"; - -const starCount = await getFormattedStars('kamranahmedse/driver.js'); ---- -
-
- -
-
- -
-
\ No newline at end of file diff --git a/docs/src/components/DocsHeader.tsx b/docs/src/components/DocsHeader.tsx new file mode 100644 index 0000000..a3f3d38 --- /dev/null +++ b/docs/src/components/DocsHeader.tsx @@ -0,0 +1,43 @@ +import { useState } from "react"; +import type { CollectionEntry } from "astro:content"; + +type DocsHeaderProps = { + groupedGuides: Record[]>; +}; + +export function DocsHeader(props: DocsHeaderProps) { + const { groupedGuides } = props; + const [isActive, setIsActive] = useState(false); + + return ( + <> +
+
+ + Astro + driver.js + +
+
+ +
+
+
+ {Object.entries(groupedGuides).map(([category, guides]) => ( +
+
{category}
+
+ {guides.map((guide) => ( + + {guide.data.title} + + ))} +
+
+ ))} +
+ + ); +} diff --git a/docs/src/components/Sidebar.astro b/docs/src/components/Sidebar.astro index adfae24..2eb077c 100644 --- a/docs/src/components/Sidebar.astro +++ b/docs/src/components/Sidebar.astro @@ -1,24 +1,15 @@ --- import { getCollection, getEntry } from "astro:content"; import { getFormattedStars } from "../lib/github"; +import { getAllGuides } from "../lib/guide"; export interface Props { activePath: string; } -const allGuides = await getCollection("guides"); -const sortedGuides = allGuides.sort((a, b) => a.data.sort - b.data.sort); -const groupedGuides = sortedGuides.reduce((acc, curr) => { - const { groupTitle } = curr.data; - acc[groupTitle] = acc[groupTitle] || []; - acc[groupTitle].push(curr); - - return acc; -}, {}); +const groupedGuides = getAllGuides(); const { activePath } = Astro.props; - -const starCount = getFormattedStars("kamranahmedse/driver.js"); ---