feat(comments): Auto-open accordion wenn Kommentare vorhanden, Pages-Support
Deploy / verify (push) Successful in 1m1s
Deploy / deploy (push) Successful in 1m11s

- 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:
Peter Meier
2026-06-03 09:22:03 +02:00
parent 6546f7d0a3
commit df4380409e
4 changed files with 30 additions and 2 deletions
+9 -1
View File
@@ -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,