From b0af8ba3293c85af8a1360b132a1ea1c7467744b Mon Sep 17 00:00:00 2001 From: Sebastian Frank Date: Sun, 17 May 2026 15:23:48 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20add=20protected=20fields=20?= =?UTF-8?q?to=20comments=20and=20enhance=20comments=20aggregation=20logic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/collections/comments.yml | 3 +++ api/config.yml.env | 2 +- frontend/src/App.svelte | 17 ++++++++++++----- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/api/collections/comments.yml b/api/collections/comments.yml index eaffb26..22fe39e 100644 --- a/api/collections/comments.yml +++ b/api/collections/comments.yml @@ -47,6 +47,7 @@ fields: widget: foreignKey foreign: collection: content + protected: true - name: author type: string @@ -54,6 +55,7 @@ fields: required: true meta: label: { de: "Autor", en: "Author" } + protected: true - name: message type: string @@ -62,3 +64,4 @@ fields: meta: label: { de: "Nachricht", en: "Message" } widget: textarea + protected: true diff --git a/api/config.yml.env b/api/config.yml.env index dc83038..6555de5 100644 --- a/api/config.yml.env +++ b/api/config.yml.env @@ -1,2 +1,2 @@ ADMIN_TOKEN=5bdfjc78hdxn338cuhSJ -ADMIN_ASSET_VERSION=db968ab-dirty-1779030587180 +ADMIN_ASSET_VERSION=db968ab-dirty-1779031350052 diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte index 71dfd65..514b8fe 100644 --- a/frontend/src/App.svelte +++ b/frontend/src/App.svelte @@ -24,6 +24,13 @@ const CONTENT_MEDIA_LOOKUP = ["blocks.heroImage.image:medialib", "blocks.image:medialib"].join(",") const NAVIGATION_CONTENT_LOOKUP = "elements.page:content" + const CONTENT_COMMENTS_AGGREGATE = { + collection: "comments", + foreignField: "contentId", + op: "count", + filter: { active: true }, + as: "commentsCount", + } let { url = "" }: { url?: string } = $props() @@ -163,13 +170,13 @@ filter: { type: "header", language: lang }, sort: "sort", limit: 1, - lookup: NAVIGATION_CONTENT_LOOKUP + lookup: NAVIGATION_CONTENT_LOOKUP, }), getCachedEntries<"navigation">("navigation", { filter: { type: "footer", language: lang }, sort: "sort", limit: 1, - lookup: NAVIGATION_CONTENT_LOOKUP + lookup: NAVIGATION_CONTENT_LOOKUP, }), ]) headerNav = headerEntries[0] || null @@ -180,8 +187,8 @@ filter: { lang, path: routePath, active: true }, sort: "sort", limit: 1, - aggregate: "comments:contentId:count", - lookup: CONTENT_MEDIA_LOOKUP + aggregate: CONTENT_COMMENTS_AGGREGATE, + lookup: CONTENT_MEDIA_LOOKUP, }) if (contentEntries.length > 0) { @@ -195,7 +202,7 @@ try { comments = await getCachedEntries("comments", { filter: { active: true, contentId: contentEntry.id as string }, - sort: "sort" + sort: "sort", }) } catch (e) { console.error("Failed to load comments", e)