import React from 'react'; import type { Metadata } from 'next'; import { draftMode } from 'next/headers' import { notFound } from 'next/navigation'; import {fetchBlogPost, fetchBlogPosts, Widget} from "../../../../lib/contentful/blogPosts"; import Util from "node:util"; import RichText from "../../../../lib/contentful/RichText"; interface BlogPostPageParams { slug: string } interface BlogPostPageProps { params: BlogPostPageParams } export async function generateMetadata({ params }: BlogPostPageProps, parent: ResolvingMetadata): Promise { const blogPost = await fetchBlogPost({ slug: params.slug, preview: draftMode().isEnabled }) if (!blogPost) { return notFound() } return { title: blogPost.title } } function renderWidget (widget: Widget) { switch (widget.type){ case 'widgetParagraph': return ( <>

{widget.widget.subTitle}

) case 'widgetMedia': return ( ) } } export default async function BlogItem({params}: { params: BlogPostPageParams }) { const item = await fetchBlogPost({slug: params.slug, preview: draftMode().isEnabled }) console.log('BLOG POST') console.log(Util.inspect(item, {showHidden: false, depth: null, colors: true})) if (!item) notFound(); return (

{item.title}

{item.category}
{item.author?.name}
{item.createdAt}
165
Share
{item.body.map(renderWidget)}
); };