import { Metadata } from 'next'; import Image from 'next/image'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import { getPosts, getPostBySlug, getRelatedPosts } from '@/content/posts'; import { CtaBanner } from '@/components/sections/CtaBanner'; import { Calendar, User, ArrowLeft, ArrowRight } from 'lucide-react'; import { companyDetails } from '@/content/company'; interface BlogPostPageProps { params: { slug: string; }; } // Generowanie ścieżek statycznych dla wpisów export async function generateStaticParams() { const posts = getPosts(); return posts.map((post) => ({ slug: post.slug, })); } // Generowanie metadanych dla danego wpisu export async function generateMetadata({ params }: BlogPostPageProps): Promise { const { slug } = await params; const post = getPostBySlug(slug); if (!post) { return { title: 'Nie znaleziono wpisu', }; } const pageTitle = post.metaTitle || post.title; const pageDescription = post.metaDescription || post.excerpt; return { title: pageTitle, description: pageDescription, alternates: { canonical: `/blog/${post.slug}`, }, openGraph: { title: pageTitle, description: pageDescription, type: 'article', publishedTime: post.date, authors: [post.author || companyDetails.shortName], images: [ { url: post.image || '/hero.jpg', }, ], }, }; } export default async function BlogPostPage({ params }: BlogPostPageProps) { const { slug } = await params; const post = getPostBySlug(slug); if (!post) { notFound(); } const relatedPosts = getRelatedPosts(post.slug, post.category, 3); const dateObj = new Date(post.date); const formattedDate = dateObj.toLocaleDateString('pl-PL', { day: 'numeric', month: 'long', year: 'numeric' }); const categoryLabels: Record = { 'klimatyzacja': 'Klimatyzacja', 'pompy-ciepla': 'Pompy Ciepła', 'remonty': 'Remonty', 'hydraulika': 'Hydraulika', 'porady': 'Porady' }; // Ustawienie CTA dopasowanego do kategorii wpisu const getCtaLink = () => { switch(post.category) { case 'klimatyzacja': return '/klimatyzacja'; case 'pompy-ciepla': return '/pompy-ciepla'; default: return '/kontakt'; } }; // --- JSON-LD --- const jsonLdArticle = { '@context': 'https://schema.org', '@type': 'BlogPosting', headline: post.title, image: post.image, datePublished: post.date, dateModified: post.date, author: { '@type': 'Person', name: post.author || companyDetails.name, }, publisher: { '@type': 'Organization', name: companyDetails.name, logo: { '@type': 'ImageObject', url: 'https://thermcool.pl/logo.png', // MOCK URL }, }, description: post.excerpt, }; const jsonLdBreadcrumb = { '@context': 'https://schema.org', '@type': 'BreadcrumbList', itemListElement: [ { '@type': 'ListItem', position: 1, name: 'Strona Główna', item: 'https://thermcool.pl', }, { '@type': 'ListItem', position: 2, name: 'Blog', item: 'https://thermcool.pl/blog', }, { '@type': 'ListItem', position: 3, name: post.title, item: `https://thermcool.pl/blog/${post.slug}`, }, ], }; return (
{/* Skrypty JSON-LD dla SEO */}