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"; export const metadata: Metadata = { title: 'Bbuddy - Blog item', description: 'Bbuddy desc blog item' }; interface BlogPostPageParams { slug: string } interface BlogPostPageProps { params: BlogPostPageParams } export async function generateStaticParams(): Promise { const blogPosts = await fetchBlogPosts({ preview: false }) return blogPosts.map((post) => ({ slug: post.slug })) } 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)}
); };