diff --git a/src/components/Card/OverviewCard.astro b/src/components/Card/OverviewCard.astro index 84f2b0d..c2106b0 100644 --- a/src/components/Card/OverviewCard.astro +++ b/src/components/Card/OverviewCard.astro @@ -1,5 +1,7 @@ --- import client from "@/data/pocketbase" +import TagRow from "./TagRow.astro" + const { recipe } = Astro.props; const headerImage = await client.collection("images").getOne(recipe.images[0]) @@ -12,16 +14,12 @@ const image = await client.files.getURL(headerImage, headerImage.image) src={ image } /> -
-

{recipe.name}

-

{recipe.description}

+
+

{recipe.name}

+

{recipe.description}

-
- {recipe.tags.map(async tag => ( -

{ - (await client.collection("tags").getOne(tag)).name - }

- ))} +
+
\ No newline at end of file diff --git a/src/components/Card/TagRow.astro b/src/components/Card/TagRow.astro new file mode 100644 index 0000000..86b071c --- /dev/null +++ b/src/components/Card/TagRow.astro @@ -0,0 +1,33 @@ +--- +import client from "../../data/pocketbase" + +interface Props { + tagIds: string[] +} + +const { tagIds } = Astro.props + +const tags = tagIds && tagIds.length > 0 + ? await Promise.all(tagIds.map(async (tagId: string) => { + try { + const tagData = await client.collection("tags").getOne(tagId) + return { name: tagData.name, id: tagId } + } catch (error) { + return null + } + })) + : [] +--- + +
+ { + tags.map(tag => ( + // no hover:bg-white/30 :( + + {tag.name} + + )) + } +