12 lines
1.9 KiB
JavaScript
12 lines
1.9 KiB
JavaScript
import { notFound } from 'next/navigation';
|
|
import Link from 'next/link';
|
|
import { faSlug, getBlogById, getBlogs, imageUrlOf, plainText, titleOf } from '../../../../lib/meshkee-api';
|
|
|
|
export const dynamicParams = false;
|
|
export async function generateStaticParams() { const params=(await getBlogs()).map((post)=>({slug:String(post.id),titleSlug:faSlug(titleOf(post))})); return params.length?params:[{slug:'__placeholder__',titleSlug:'بدون-عنوان'}]; }
|
|
export async function generateMetadata({params}) { const {slug}=await params; const post=await getBlogById(slug); if(!post)return{robots:{index:false,follow:false}}; const title=titleOf(post,'بلاگ'); const description=post.seoMetaDescription||plainText(post.abstract||post.summary||post.mainTextHtml||'').slice(0,160)||`مقالهٔ ${title} از گروه معماری ساناز گودرزی.`; const canonical=`/blog/${post.id}/${faSlug(title)}/`; return {title:post.seoMetaTitle||title,description,alternates:{canonical},openGraph:{title,description,url:canonical,type:'article',images:imageUrlOf(post)?[{url:imageUrlOf(post),alt:title}]:[]}}; }
|
|
export default async function BlogDetail({params}) { const {slug}=await params; const post=await getBlogById(slug); if(!post)notFound(); const title=titleOf(post); const image=imageUrlOf(post); return <article className="editorial-detail container">
|
|
{post.schema?.jsonLd&&<script type="application/ld+json" dangerouslySetInnerHTML={{__html:JSON.stringify(post.schema.jsonLd)}}/>}
|
|
<Link className="text-link" href="/blog/">بازگشت به بلاگ ←</Link><span className="eyebrow">بلاگ معماری</span><h1>{title}</h1>{post.abstract&&<p className="editorial-lead">{plainText(post.abstract)}</p>}{image&&<img className="editorial-cover" src={image} alt={`تصویر شاخص مقالهٔ ${title}`}/>}<div className="rich-content" dangerouslySetInnerHTML={{__html:post.mainTextHtml||post.contentHtml||''}}/>
|
|
</article>; }
|