From 66567b9b688e35958d36f6fc40b2f1e6b24874be Mon Sep 17 00:00:00 2001 From: june Date: Wed, 13 Aug 2025 08:32:43 +1200 Subject: [PATCH] decent nice carousel working --- src/components/Detail/ImageCarousel.astro | 47 +++++++++++++++++++++++ src/components/Header.astro | 4 +- src/pages/recipe/[slug].astro | 6 ++- 3 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 src/components/Detail/ImageCarousel.astro diff --git a/src/components/Detail/ImageCarousel.astro b/src/components/Detail/ImageCarousel.astro new file mode 100644 index 0000000..08a68d8 --- /dev/null +++ b/src/components/Detail/ImageCarousel.astro @@ -0,0 +1,47 @@ +--- +import client from "@/data/pocketbase"; +const { recipe } = Astro.props + +async function getLink(img: string) { + const record = await client.collection("images").getOne(img) + const link = await client.files.getURL(record, record.image) + return link +} + +// Use Promise.all to wait for all async operations to complete +const links = await Promise.all( + recipe.images.map((img: string) => getLink(img)) +) + +--- + + + +
+ + + + + + +
\ No newline at end of file diff --git a/src/components/Header.astro b/src/components/Header.astro index c582951..2bb3951 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -1,8 +1,8 @@
-

Reci

-

pie

+

Recipie

+ 🥧
diff --git a/src/pages/recipe/[slug].astro b/src/pages/recipe/[slug].astro index 36682eb..ec3f634 100644 --- a/src/pages/recipe/[slug].astro +++ b/src/pages/recipe/[slug].astro @@ -1,6 +1,8 @@ --- import client from "@/data/pocketbase"; import SiteLayout from "@/layouts/base"; +import ImageCarousel from "@/components/Detail/ImageCarousel"; + const { slug } = Astro.params; const re = await client.collection("recipes").getOne(slug ?? "0"); @@ -8,5 +10,7 @@ const re = await client.collection("recipes").getOne(slug ?? "0"); --- - {re.name} +
+ +
\ No newline at end of file