Fix RSC build break: keep next/headers out of lib/payload.ts
payload.ts's mapping functions/types are also imported by "use client" components (LiveTestimonialsGrid, LivePostContent) — importing next/headers anywhere in that module made it unbundlable for the client, breaking the production build. draftMode() is now only ever called in the Server Component pages themselves; they pass the resulting boolean into getPostBySlug/getLegalPage/getTestimonials as a plain `draft` option.
This commit is contained in:
@@ -39,7 +39,8 @@ export default async function BlogDetailPage({
|
||||
params: Promise<{ slug: string }>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
const post = await getPostBySlug(slug);
|
||||
const { isEnabled: isPreview } = await draftMode();
|
||||
const post = await getPostBySlug(slug, { draft: isPreview });
|
||||
if (!post) notFound();
|
||||
|
||||
// "Weiterlesen" — any other post, most recent first. Not the current
|
||||
@@ -47,7 +48,6 @@ export default async function BlogDetailPage({
|
||||
// showing a fake/duplicate card when this is the only post.
|
||||
const otherPosts = await getBlogPosts(4);
|
||||
const nextPost = otherPosts.find((p) => p.slug !== post.slug) ?? null;
|
||||
const { isEnabled: isPreview } = await draftMode();
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user