✨ feat: add protected fields to comments and enhance comments aggregation logic
This commit is contained in:
@@ -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
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
ADMIN_TOKEN=5bdfjc78hdxn338cuhSJ
|
||||
ADMIN_ASSET_VERSION=db968ab-dirty-1779030587180
|
||||
ADMIN_ASSET_VERSION=db968ab-dirty-1779031350052
|
||||
|
||||
+12
-5
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user