feat: unify API options structure and enhance lookup handling across collections

This commit is contained in:
2026-05-17 14:53:52 +00:00
parent f332c707b7
commit bd8d413850
10 changed files with 58 additions and 112 deletions
+23 -39
View File
@@ -159,45 +159,30 @@
try {
// Load navigation
const [headerEntries, footerEntries] = await Promise.all([
getCachedEntries<"navigation">(
"navigation",
{ type: "header", language: lang },
"sort",
1,
undefined,
undefined,
undefined,
NAVIGATION_CONTENT_LOOKUP
),
getCachedEntries<"navigation">(
"navigation",
{ type: "footer", language: lang },
"sort",
1,
undefined,
undefined,
undefined,
NAVIGATION_CONTENT_LOOKUP
),
getCachedEntries<"navigation">("navigation", {
filter: { type: "header", language: lang },
sort: "sort",
limit: 1,
lookup: NAVIGATION_CONTENT_LOOKUP
}),
getCachedEntries<"navigation">("navigation", {
filter: { type: "footer", language: lang },
sort: "sort",
limit: 1,
lookup: NAVIGATION_CONTENT_LOOKUP
}),
])
headerNav = headerEntries[0] || null
footerNav = footerEntries[0] || null
// Load content for current path. Limit 1 so SSR tracks content:<id> instead of content:*.
const contentEntries = await getCachedEntries<"content">(
"content",
{
lang,
path: routePath,
active: true,
},
"sort",
1,
undefined,
undefined,
{ aggregate: "comments:contentId:count" },
CONTENT_MEDIA_LOOKUP
)
const contentEntries = await getCachedEntries<"content">("content", {
filter: { lang, path: routePath, active: true },
sort: "sort",
limit: 1,
aggregate: "comments:contentId:count",
lookup: CONTENT_MEDIA_LOOKUP
})
if (contentEntries.length > 0) {
contentEntry = contentEntries[0]
@@ -208,11 +193,10 @@
}
try {
comments = await getCachedEntries(
"comments",
{ active: true, contentId: contentEntry.id as string },
"sort"
)
comments = await getCachedEntries("comments", {
filter: { active: true, contentId: contentEntry.id as string },
sort: "sort"
})
} catch (e) {
console.error("Failed to load comments", e)
comments = []