✨ feat: add protected fields to comments and enhance comments aggregation logic
This commit is contained in:
@@ -47,6 +47,7 @@ fields:
|
|||||||
widget: foreignKey
|
widget: foreignKey
|
||||||
foreign:
|
foreign:
|
||||||
collection: content
|
collection: content
|
||||||
|
protected: true
|
||||||
|
|
||||||
- name: author
|
- name: author
|
||||||
type: string
|
type: string
|
||||||
@@ -54,6 +55,7 @@ fields:
|
|||||||
required: true
|
required: true
|
||||||
meta:
|
meta:
|
||||||
label: { de: "Autor", en: "Author" }
|
label: { de: "Autor", en: "Author" }
|
||||||
|
protected: true
|
||||||
|
|
||||||
- name: message
|
- name: message
|
||||||
type: string
|
type: string
|
||||||
@@ -62,3 +64,4 @@ fields:
|
|||||||
meta:
|
meta:
|
||||||
label: { de: "Nachricht", en: "Message" }
|
label: { de: "Nachricht", en: "Message" }
|
||||||
widget: textarea
|
widget: textarea
|
||||||
|
protected: true
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
ADMIN_TOKEN=5bdfjc78hdxn338cuhSJ
|
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 CONTENT_MEDIA_LOOKUP = ["blocks.heroImage.image:medialib", "blocks.image:medialib"].join(",")
|
||||||
const NAVIGATION_CONTENT_LOOKUP = "elements.page:content"
|
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()
|
let { url = "" }: { url?: string } = $props()
|
||||||
|
|
||||||
@@ -163,13 +170,13 @@
|
|||||||
filter: { type: "header", language: lang },
|
filter: { type: "header", language: lang },
|
||||||
sort: "sort",
|
sort: "sort",
|
||||||
limit: 1,
|
limit: 1,
|
||||||
lookup: NAVIGATION_CONTENT_LOOKUP
|
lookup: NAVIGATION_CONTENT_LOOKUP,
|
||||||
}),
|
}),
|
||||||
getCachedEntries<"navigation">("navigation", {
|
getCachedEntries<"navigation">("navigation", {
|
||||||
filter: { type: "footer", language: lang },
|
filter: { type: "footer", language: lang },
|
||||||
sort: "sort",
|
sort: "sort",
|
||||||
limit: 1,
|
limit: 1,
|
||||||
lookup: NAVIGATION_CONTENT_LOOKUP
|
lookup: NAVIGATION_CONTENT_LOOKUP,
|
||||||
}),
|
}),
|
||||||
])
|
])
|
||||||
headerNav = headerEntries[0] || null
|
headerNav = headerEntries[0] || null
|
||||||
@@ -180,8 +187,8 @@
|
|||||||
filter: { lang, path: routePath, active: true },
|
filter: { lang, path: routePath, active: true },
|
||||||
sort: "sort",
|
sort: "sort",
|
||||||
limit: 1,
|
limit: 1,
|
||||||
aggregate: "comments:contentId:count",
|
aggregate: CONTENT_COMMENTS_AGGREGATE,
|
||||||
lookup: CONTENT_MEDIA_LOOKUP
|
lookup: CONTENT_MEDIA_LOOKUP,
|
||||||
})
|
})
|
||||||
|
|
||||||
if (contentEntries.length > 0) {
|
if (contentEntries.length > 0) {
|
||||||
@@ -195,7 +202,7 @@
|
|||||||
try {
|
try {
|
||||||
comments = await getCachedEntries("comments", {
|
comments = await getCachedEntries("comments", {
|
||||||
filter: { active: true, contentId: contentEntry.id as string },
|
filter: { active: true, contentId: contentEntry.id as string },
|
||||||
sort: "sort"
|
sort: "sort",
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Failed to load comments", e)
|
console.error("Failed to load comments", e)
|
||||||
|
|||||||
Reference in New Issue
Block a user