import type { Metadata, ResolvingMetadata } from 'next';
import { getArticleBySlug } from '@/lib/db';
type Props = { params: { slug: string } };
export async function generateMetadata(
{ params }: Props,
parent: ResolvingMetadata
): Promise<Metadata> {
const article = await getArticleBySlug(params.slug);
if (!article) return { title: "Article Not Found | Cortinex" };
const canonicalUrl = `https://www.cortinex-webstudio.com/blog/${article.slug}`;
return {
title: `${article.title} | Cortinex Intelligence`,
description: article.description,
alternates: {
canonical: canonicalUrl,
},
openGraph: {
title: article.title,
description: article.description,
url: canonicalUrl,
type: 'article',
publishedTime: article.publishedAt,
modifiedTime: article.updatedAt,
images: [{ url: article.heroImage, width: 1200, height: 630, alt: article.title }],
},
twitter: {
card: 'summary_large_image',
title: article.title,
description: article.description,
images: [article.heroImage],
},
robots: {
index: !article.noIndex,
follow: !article.noIndex,
googleBot: {
index: !article.noIndex,
follow: !article.noIndex,
'max-video-preview': -1,
'max-image-preview': 'large',
'max-snippet': -1,
},
},
};
}