[PIE-16] Basic tag page implementation #13

Merged
breadone merged 5 commits from PIE-16 into main 2025-08-16 23:17:31 +12:00
6 changed files with 38 additions and 5 deletions
Showing only changes of commit 1cffd0b7e7 - Show all commits

View File

@ -7,8 +7,9 @@
</a>
<div class="ml-auto space-x-5">
<a class="hover:underline underline-offset-4 " href="/recipe/new">new</a>
<a class="hover:underline underline-offset-4 " >tags</a>
<a class="hover:underline underline-offset-4 " >search</a>
<a class="hover:underline underline-offset-4" href="/recipe/new">new</a>
<a class="hover:underline underline-offset-4" href="/recipe/import">add</a>
<!-- <a class="hover:underline underline-offset-4" href="/tags">tags</a> -->
<a class="hover:underline underline-offset-4" >search</a>
</div>
</div>

View File

@ -44,6 +44,10 @@ class APIClient {
return urls
}
async getAllTags() {
return await this.client.collection<Tag>(Collection.TAGS).getFullList()
}
async getTag(name: string) {
return await this.client.collection<Tag>(Collection.TAGS).getList(1, 50, { filter: `name = '${name}'` })
}

View File

@ -9,7 +9,7 @@ const recipes = await client.getAllRecipes()
<PageLayout>
<!-- <p class="pb-2">What would you like today?</p> -->
<div class="grid md:gap-2 gap-3 grid-cols-2 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-8">
<div class="grid gap-3 grid-cols-1 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-6">
{
recipes.map(r => (
<OverviewCard recipe={r} />

View File

@ -9,7 +9,7 @@ const recipes = await client.getRecipesOfTag(name) // todo redir to 404 if not f
<SiteLayout>
<p class="text-xl pb-2">
{recipes.length} { recipes.length == 1 ? "Recipe" : "Recipes" } with: <code class="bg-white/10 px-1 rounded-lg" >{name}</code>
{recipes.length} { recipes.length == 1 ? "Recipe" : "Recipes" } with: <code class="bg-white/10 p-1 text-sm rounded-lg" >{name}</code>
</p>
<div class="grid md:gap-2 gap-3 grid-cols-2 md:grid-cols-2 lg:grid-cols-4 xl:grid-cols-8">

View File

@ -0,0 +1,24 @@
---
import client from "@/data/pocketbase";
import SiteLayout from "@/layouts/base";
const tags = await client.getAllTags()
const countsPerTag = await Promise.all(
tags.map(async t => (await client.getRecipesOfTag(t.name)).length)
)
---
<SiteLayout>
<p class="title pb-2">
{tags.length} Tags
</p>
{
(tags ?? []).map((t, i) => (
// <p>{t.name} -&gt; {countsPerTag[i]} {countsPerTag[i] == 1 ? "Recipe" : "Recipes" } </p>
<a class="hover:underline" href={`/tags/${t.name}`}>
{t.name} ({countsPerTag[i]})
</a><br/>
))
}
</SiteLayout>

View File

@ -7,4 +7,8 @@ html {
/* @apply font-; */
@apply font-sans;
/* font-family: 'SF Pro Display', 'Segoe UI', 'Helvetica Neue', Arial, 'Noto Sans', sans-serif; */
}
.title {
@apply text-2xl;
}