import { url, getAuthor } from '@/app/layout.config'; import { SingleSwirl } from '@/components/Swirls'; import { ArticleCard } from '@/components/article-card'; import { Logo } from '@/components/logo'; import { SectionHeader } from '@/components/section'; import { Toc } from '@/components/toc'; import { Button } from '@/components/ui/button'; import { articleSource } from '@/lib/source'; import { ArrowLeftIcon } from 'lucide-react'; import type { Metadata } from 'next'; import Image from 'next/image'; import Link from 'next/link'; import { notFound } from 'next/navigation'; import Script from 'next/script'; export async function generateMetadata({ params, }: { params: Promise<{ articleSlug: string }>; }): Promise { const { articleSlug } = await params; const article = await articleSource.getPage([articleSlug]); const author = getAuthor(article?.data.team); if (!article) { return { title: 'Article Not Found', }; } return { title: article.data.title, description: article.data.description, authors: [{ name: author.name }], alternates: { canonical: url(article.url), }, openGraph: { title: article.data.title, description: article.data.description, type: 'article', publishedTime: article.data.date.toISOString(), authors: author.name, images: url(article.data.cover), url: url(article.url), }, twitter: { card: 'summary_large_image', title: article.data.title, description: article.data.description, images: url(article.data.cover), }, }; } export default async function Page({ params, }: { params: Promise<{ articleSlug: string }>; }) { const { articleSlug } = await params; const article = await articleSource.getPage([articleSlug]); const Body = article?.data.body; const author = getAuthor(article?.data.team); const goBackUrl = '/articles'; const relatedArticles = (await articleSource.getPages()) .filter( (item) => item.data.tag === article?.data.tag && item.url !== article?.url, ) .sort((a, b) => b.data.date.getTime() - a.data.date.getTime()); if (!Body) { return notFound(); } // Create the JSON-LD data const jsonLd = { '@context': 'https://schema.org', '@type': 'Article', headline: article?.data.title, datePublished: article?.data.date.toISOString(), author: { '@type': 'Person', name: author.name, }, publisher: { '@type': 'Organization', name: 'OpenPanel', logo: { '@type': 'ImageObject', url: url('/logo.png'), }, }, mainEntityOfPage: { '@type': 'WebPage', '@id': url(article.url), }, image: { '@type': 'ImageObject', url: url(article.data.cover), }, }; return (