import Link from 'next/link' import { ArrowLeft } from 'lucide-react' import type { ReactNode } from 'react' import type { BlogPost as BlogPostType } from '@startsimpli/api/blog' import { MarkdownRenderer } from './MarkdownRenderer' import { JsonLd } from './JsonLd' import { cn } from '../../utils/cn' export interface BlogPostProps { post: BlogPostType /** Pre-resolved featured-image URL (pass the client's `getImageUrl`). */ imageSrc?: string /** Index route, e.g. `/blog`. Used for breadcrumb + back link. */ basePath?: string /** Label for the index in the breadcrumb / back link. Default "Blog". */ indexLabel?: string /** Byline shown in the article meta. */ byline?: string /** Syntax-highlight theme forwarded to the markdown renderer. */ theme?: 'light' | 'dark' /** schema.org JSON-LD object(s) rendered into the page head. */ structuredData?: object | object[] /** Left-rail outline, e.g. ``. Sticky on lg+. */ toc?: ReactNode /** Optional sidebar (share widgets, CTAs). Rendered right of the content on lg+. */ sidebar?: ReactNode className?: string } /** * Full article-detail composer: JSON-LD, breadcrumb, title, byline/date, * featured image, themed markdown body, optional sidebar, and back link. * Per-app code reduces to fetching the post and rendering ``. */ export function BlogPost({ post, imageSrc, basePath = '/blog', indexLabel = 'Blog', byline, theme = 'light', structuredData, toc, sidebar, className, }: BlogPostProps) { const featured = imageSrc ?? post.image const publishedLabel = post.publishedAt ? new Date(post.publishedAt).toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' }) : null const mainColClass = toc && sidebar ? 'lg:col-span-6' : toc ? 'lg:col-span-9' : sidebar ? 'lg:col-span-8' : 'max-w-3xl mx-auto w-full' return (
{structuredData && }
{toc && ( )}

{post.title}

{byline && {byline}} {publishedLabel && ( )} {post.readTime && ( <> {post.readTime} )}
{featured && (
{/* eslint-disable-next-line @next/next/no-img-element */} {post.title}
)}
Back to {indexLabel}
{sidebar && ( )}
) }