got da card working

This commit is contained in:
2025-11-17 14:27:02 +13:00
parent 02724d9986
commit 38691dc357
4 changed files with 43 additions and 8 deletions

View File

@@ -1,13 +1,27 @@
--- ---
import TagRow from "@component/tagRow"
const { title, description, tags } = Astro.props const { id, title, description, tags, image } = Astro.props
--- ---
<div> <div class="relative z-0 flex h-50">
{title}<br> <img
class="w-full h-full object-cover rounded-xl"
src={ image }
/>
{description}<br> <div id="bottom-info-panel" class="absolute bottom-0 left-0 w-full p-2 h-20 backdrop-filter backdrop-blur-lg rounded-b-xl z-1">
<p id="recipe-name" class="text-[14pt] text-white opacity-90 font-bold line-clamp-1" >{title}</p>
<!-- <p id="recipe-desc" class="text-white text-[10pt]"> {recipe.description} </p> -->
{tags.join(", ")}<br> <div id="tag-row" class="">
<TagRow tags={tags}/>
</div>
</div>
<a id="link" href={`/recipe/${id}`} class="absolute inset-0 z-0">
<span class="block w-full h-full hover:bg-black/10 transition-colors">
</span>
</a>
</div> </div>

View File

@@ -0,0 +1,16 @@
---
const { tags } = Astro.props
---
<div class="">
{
(tags ?? []).map(tag => (
<a
href={`/tags/${tag}`}
class="text-white bg-white/20 px-2 mr-2 mt-2 rounded-md inline-block hover:bg-white/30"
>
{tag}
</a>
))
}
</div>

View File

@@ -1,7 +1,5 @@
import PocketBase from "pocketbase"; import PocketBase from "pocketbase";
console.log("STUFF", import.meta.env.PUBLIC_PB_URL)
const pb = new PocketBase(import.meta.env.PUBLIC_PB_URL); const pb = new PocketBase(import.meta.env.PUBLIC_PB_URL);
pb.autoCancellation(false) pb.autoCancellation(false)

View File

@@ -3,20 +3,27 @@ import { Recipe } from "@tmlmt/cooklang-parser"
import { authPB } from "@data/pb"; import { authPB } from "@data/pb";
import RecipeCard from "@component/index/card" import RecipeCard from "@component/index/card"
import Base from "@layout/Base"; import Base from "@layout/Base";
import { record } from "astro:schema";
const pb = await authPB() const pb = await authPB()
const records = await pb.collection('recipes').getFullList() const records = await pb.collection('recipes').getFullList()
const recipes = records.map(r => new Recipe(r.cooklang)) const recipes = records.map(r => new Recipe(r.cooklang))
const ids = records.map(r => r.id)
const images = await Promise.all(
records.map(r => pb.files.getURL(r, r.images[0])) // get first image from each recipe as a cover image
)
--- ---
<Base> <Base>
{ {
recipes.map(r => ( recipes.map((r, i) => (
<RecipeCard <RecipeCard
id={ids[i]}
title={r.metadata.title ?? "Untitled Recipe"} title={r.metadata.title ?? "Untitled Recipe"}
description={r.metadata.description ?? "No Description"} description={r.metadata.description ?? "No Description"}
tags={r.metadata.tags ?? []} tags={r.metadata.tags ?? []}
image={images[i]}
/> />
)) ))
} }