diff --git a/src/app/(category-sidebar)/[collection]/page.tsx b/src/app/(category-sidebar)/[collection]/page.tsx new file mode 100644 index 0000000..55fcf75 --- /dev/null +++ b/src/app/(category-sidebar)/[collection]/page.tsx @@ -0,0 +1,53 @@ +import { Link } from "@/components/ui/link"; +import { db } from "@/db"; +import { products } from "@/db/schema"; +import { count } from "drizzle-orm"; +import Image from "next/image"; + +export default async function Home(props: { + params: { + collection: string; + }; +}) { + const collections = await db.query.collections.findMany({ + with: { + categories: true, + }, + where: (collections, { eq }) => + eq(collections.name, decodeURIComponent(props.params.collection)), + orderBy: (collections, { asc }) => asc(collections.name), + }); + let imageCount = 0; + + return ( +
+ {collections.map((collection) => ( +
+

{collection.name}

+
+ {collection.categories.map((category) => ( + + {`A + {category.name} + + ))} +
+
+ ))} +
+ ); +} diff --git a/src/app/(category-sidebar)/layout.tsx b/src/app/(category-sidebar)/layout.tsx index 36bb83b..1924c68 100644 --- a/src/app/(category-sidebar)/layout.tsx +++ b/src/app/(category-sidebar)/layout.tsx @@ -6,12 +6,15 @@ export default async function Layout({ }: { children: React.ReactNode; }) { - const allCategories = await db.query.categories.findMany({ - orderBy: (categories, { asc }) => asc(categories.name), + const allCategories = await db.query.collections.findMany({ + with: { + categories: true, + }, + orderBy: (collections, { asc }) => asc(collections.name), }); return ( -
-