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