diff --git a/src/components/Header.astro b/src/components/Header.astro index 28dd602..89595c5 100644 --- a/src/components/Header.astro +++ b/src/components/Header.astro @@ -7,8 +7,9 @@
- new - tags - search + new + add + + search
\ No newline at end of file diff --git a/src/data/pocketbase.ts b/src/data/pocketbase.ts index c3f6c9a..8684c0a 100644 --- a/src/data/pocketbase.ts +++ b/src/data/pocketbase.ts @@ -44,6 +44,10 @@ class APIClient { return urls } + async getAllTags() { + return await this.client.collection(Collection.TAGS).getFullList() + } + async getTag(name: string) { return await this.client.collection(Collection.TAGS).getList(1, 50, { filter: `name = '${name}'` }) } diff --git a/src/pages/index.astro b/src/pages/index.astro index 592c409..b7a4865 100644 --- a/src/pages/index.astro +++ b/src/pages/index.astro @@ -9,7 +9,7 @@ const recipes = await client.getAllRecipes() -
+
{ recipes.map(r => ( diff --git a/src/pages/tags/[name].astro b/src/pages/tags/[name].astro index 1d60ca2..4d0285a 100644 --- a/src/pages/tags/[name].astro +++ b/src/pages/tags/[name].astro @@ -9,7 +9,7 @@ const recipes = await client.getRecipesOfTag(name) // todo redir to 404 if not f

- {recipes.length} { recipes.length == 1 ? "Recipe" : "Recipes" } with: {name} + {recipes.length} { recipes.length == 1 ? "Recipe" : "Recipes" } with: {name}

diff --git a/src/pages/tags/index.astro b/src/pages/tags/index.astro index e69de29..0f691a4 100644 --- a/src/pages/tags/index.astro +++ b/src/pages/tags/index.astro @@ -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) +) +--- + + +

+ {tags.length} Tags +

+ { + (tags ?? []).map((t, i) => ( + //

{t.name} -> {countsPerTag[i]} {countsPerTag[i] == 1 ? "Recipe" : "Recipes" }

+ + {t.name} ({countsPerTag[i]}) +
+ )) + } +
\ No newline at end of file diff --git a/src/styles/global.css b/src/styles/global.css index 12ec143..bdf651e 100644 --- a/src/styles/global.css +++ b/src/styles/global.css @@ -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; } \ No newline at end of file