From 57d74afc38ecd9bfa44f287ac3657507fee0f973 Mon Sep 17 00:00:00 2001 From: Vula Builder Date: Wed, 29 Jul 2026 19:04:22 +0000 Subject: [PATCH] Deploy --- src/app/blog/[slug]/page.tsx | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 src/app/blog/[slug]/page.tsx diff --git a/src/app/blog/[slug]/page.tsx b/src/app/blog/[slug]/page.tsx new file mode 100644 index 0000000..3d66fb4 --- /dev/null +++ b/src/app/blog/[slug]/page.tsx @@ -0,0 +1,70 @@ +import { notFound } from 'next/navigation' +import Link from 'next/link' +import Image from 'next/image' +import { getBlogPosts } from '@/lib/cms' + +export const revalidate = 60 + +export async function generateStaticParams() { + const posts = await getBlogPosts(50) + return posts.map(p => ({ slug: (p.data.slug as string) ?? p.id })) +} + +export default async function BlogPostPage({ params }: { params: Promise<{ slug: string }> }) { + const { slug } = await params + const posts = await getBlogPosts(50) + const post = posts.find(p => (p.data.slug as string) === slug || p.id === slug) + + if (!post) notFound() + + const { title, excerpt, body, cover_image, author, category } = post.data as { + title?: string; excerpt?: string; body?: string; + cover_image?: string; author?: string; category?: string + } + + const paragraphs = (body || excerpt || '').split(/\n\n+/).filter(Boolean) + const date = post.publishedAt + ? new Date(post.publishedAt).toLocaleDateString('en-ZA', { year: 'numeric', month: 'long', day: 'numeric' }) + : '' + + return ( +
+ {cover_image && ( +
+ {title +
+
+ )} + +
+ + ← Back to blog + + + {category && ( + {category} + )} + +

+ {title} +

+ +
+ {author && {author}} + {author && date && ·} + {date && {date}} +
+ + {excerpt && paragraphs.length <= 1 && ( +

{excerpt}

+ )} + +
+ {paragraphs.map((para, i) => ( +

{para}

+ ))} +
+
+
+ ) +}