feat(comments): Auto-open accordion wenn Kommentare vorhanden, Pages-Support
- Post: Kommentar-Count server-seitig laden, Accordion offen wenn count > 0 - Page-Route: optionale Kommentare via commentsEnabled-Flag (Schema: default false) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import type { PageServerLoad } from './$types';
|
||||
import { getPageBySlug } from '$lib/cms';
|
||||
import { getPageBySlug, getCommentCounts } from '$lib/cms';
|
||||
import {
|
||||
extractCmsImageField,
|
||||
ensureTransformedImage,
|
||||
@@ -130,9 +130,17 @@ export const load: PageServerLoad = async ({ params, locals, fetch, url, setHead
|
||||
}
|
||||
}
|
||||
|
||||
const commentsEnabled = !!(page as { commentsEnabled?: boolean }).commentsEnabled;
|
||||
const commentPageId = commentsEnabled ? (page._slug ?? slug) : null;
|
||||
const commentCount = commentPageId
|
||||
? (await getCommentCounts([commentPageId]))[commentPageId] ?? 0
|
||||
: 0;
|
||||
|
||||
return {
|
||||
page,
|
||||
translations,
|
||||
commentPageId,
|
||||
commentCount,
|
||||
preview: !!preview,
|
||||
previewDraft: !!previewDraft,
|
||||
seoTitle: page.seoTitle ?? page.headline ?? page.linkName ?? slug,
|
||||
|
||||
Reference in New Issue
Block a user