From 9a1a7a504c065cc4b5063c2109deef4e4513814d Mon Sep 17 00:00:00 2001 From: june Date: Tue, 12 Aug 2025 23:18:02 +1200 Subject: [PATCH] Add tags view :) --- api/pb_migrations/1754996900_created_tags.js | 71 +++++++++++++++++++ .../1754996921_updated_recipes.js | 28 ++++++++ api/pb_migrations/1754997089_updated_tags.js | 28 ++++++++ src/components/Card/OverviewCard.astro | 9 +++ 4 files changed, 136 insertions(+) create mode 100644 api/pb_migrations/1754996900_created_tags.js create mode 100644 api/pb_migrations/1754996921_updated_recipes.js create mode 100644 api/pb_migrations/1754997089_updated_tags.js diff --git a/api/pb_migrations/1754996900_created_tags.js b/api/pb_migrations/1754996900_created_tags.js new file mode 100644 index 0000000..a94197e --- /dev/null +++ b/api/pb_migrations/1754996900_created_tags.js @@ -0,0 +1,71 @@ +/// +migrate((app) => { + const collection = new Collection({ + "createRule": null, + "deleteRule": null, + "fields": [ + { + "autogeneratePattern": "[a-z0-9]{15}", + "hidden": false, + "id": "text3208210256", + "max": 15, + "min": 15, + "name": "id", + "pattern": "^[a-z0-9]+$", + "presentable": false, + "primaryKey": true, + "required": true, + "system": true, + "type": "text" + }, + { + "autogeneratePattern": "", + "hidden": false, + "id": "text1579384326", + "max": 0, + "min": 0, + "name": "name", + "pattern": "", + "presentable": false, + "primaryKey": false, + "required": false, + "system": false, + "type": "text" + }, + { + "hidden": false, + "id": "autodate2990389176", + "name": "created", + "onCreate": true, + "onUpdate": false, + "presentable": false, + "system": false, + "type": "autodate" + }, + { + "hidden": false, + "id": "autodate3332085495", + "name": "updated", + "onCreate": true, + "onUpdate": true, + "presentable": false, + "system": false, + "type": "autodate" + } + ], + "id": "pbc_1219621782", + "indexes": [], + "listRule": null, + "name": "tags", + "system": false, + "type": "base", + "updateRule": null, + "viewRule": null + }); + + return app.save(collection); +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_1219621782"); + + return app.delete(collection); +}) diff --git a/api/pb_migrations/1754996921_updated_recipes.js b/api/pb_migrations/1754996921_updated_recipes.js new file mode 100644 index 0000000..e66c6ef --- /dev/null +++ b/api/pb_migrations/1754996921_updated_recipes.js @@ -0,0 +1,28 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_842702175") + + // add field + collection.fields.addAt(6, new Field({ + "cascadeDelete": false, + "collectionId": "pbc_1219621782", + "hidden": false, + "id": "relation1874629670", + "maxSelect": 999, + "minSelect": 0, + "name": "tags", + "presentable": false, + "required": false, + "system": false, + "type": "relation" + })) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_842702175") + + // remove field + collection.fields.removeById("relation1874629670") + + return app.save(collection) +}) diff --git a/api/pb_migrations/1754997089_updated_tags.js b/api/pb_migrations/1754997089_updated_tags.js new file mode 100644 index 0000000..17fd1ad --- /dev/null +++ b/api/pb_migrations/1754997089_updated_tags.js @@ -0,0 +1,28 @@ +/// +migrate((app) => { + const collection = app.findCollectionByNameOrId("pbc_1219621782") + + // update collection data + unmarshal({ + "createRule": "", + "deleteRule": "", + "listRule": "", + "updateRule": "", + "viewRule": "" + }, collection) + + return app.save(collection) +}, (app) => { + const collection = app.findCollectionByNameOrId("pbc_1219621782") + + // update collection data + unmarshal({ + "createRule": null, + "deleteRule": null, + "listRule": null, + "updateRule": null, + "viewRule": null + }, collection) + + return app.save(collection) +}) diff --git a/src/components/Card/OverviewCard.astro b/src/components/Card/OverviewCard.astro index 6736237..84f2b0d 100644 --- a/src/components/Card/OverviewCard.astro +++ b/src/components/Card/OverviewCard.astro @@ -14,5 +14,14 @@ const image = await client.files.getURL(headerImage, headerImage.image)

{recipe.name}

+

{recipe.description}

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

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

+ ))} +
\ No newline at end of file