import Image from "next/image"; import Link from "next/link"; import { getLocale, getTranslations } from "next-intl/server"; import { ArrowRight, Github } from "lucide-react"; import { RelatedGuides } from "@/components/marketing/related-guides"; import { SiteFooter } from "@/components/marketing/site-footer"; import { intlLocale } from "@/i18n/config"; import { type BlogPost, getSiteUrl } from "@/lib/blog-posts"; import { GITHUB_URL } from "@/lib/site"; export interface ArticleFaq { question: string; answer: string; } export const articleProseClassName = "space-y-6 leading-8 [&_h2]:scroll-mt-8 [&_h2]:pt-6 [&_h2]:text-2xl [&_h2]:font-bold [&_h2]:tracking-tight [&_h3]:pt-2 [&_h3]:text-lg [&_h3]:font-semibold [&_a]:font-medium [&_a]:underline [&_a]:underline-offset-4 [&_p]:text-muted-foreground [&_li]:text-muted-foreground [&_ul]:ml-5 [&_ul]:list-disc [&_ul]:space-y-2 [&_ol]:ml-5 [&_ol]:list-decimal [&_ol]:space-y-2 [&_code]:rounded [&_code]:bg-muted [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:font-mono [&_code]:text-[0.85em] [&_code]:text-foreground"; export function formatArticleDate(date: string, locale: string) { return new Intl.DateTimeFormat(intlLocale(locale), { dateStyle: "long", timeZone: "UTC" }).format(new Date(`${date}T00:00:00.000Z`)); } export function CodeBlock({ children, label }: { children: string; label?: string }) { return (
{label ?
{label}
: null}
{children.trim()}
); } /** Header, breadcrumb, JSON-LD, related links, and footer shared by long-form blog articles. */ export async function ArticleShell({ post, breadcrumb, toc, faqs, cta, videos = [], children, }: { post: BlogPost; breadcrumb: string; toc: Array<[id: string, label: string]>; faqs: ArticleFaq[]; cta?: { title: string; body: string; label: string; href?: string }; videos?: Array>; children: React.ReactNode; }) { const locale = post.language ?? await getLocale(); const t = await getTranslations({ locale, namespace: "blog" }); const siteUrl = getSiteUrl(); const url = `${siteUrl}/blog/${post.slug}`; const updatedLabel = formatArticleDate(post.updatedAt, locale); const structuredData = { "@context": "https://schema.org", "@graph": [ ...videos, { "@type": "BreadcrumbList", itemListElement: [ { "@type": "ListItem", position: 1, name: t("shell.home"), item: siteUrl }, { "@type": "ListItem", position: 2, name: t("shell.blog"), item: `${siteUrl}/blog` }, { "@type": "ListItem", position: 3, name: breadcrumb, item: url }, ], }, { "@type": "BlogPosting", headline: post.title, description: post.description, datePublished: post.publishedAt, dateModified: post.updatedAt, author: { "@type": "Organization", name: post.author }, publisher: { "@type": "Organization", name: "SupoClip", url: siteUrl, logo: { "@type": "ImageObject", url: `${siteUrl}/logo.png` } }, articleSection: post.category, keywords: post.keywords.join(", "), inLanguage: intlLocale(locale), mainEntityOfPage: url, image: post.image ? `${siteUrl}${post.image.src}` : undefined, }, { "@type": "FAQPage", mainEntity: faqs.map(({ question, answer }) => ({ "@type": "Question", name: question, acceptedAnswer: { "@type": "Answer", text: answer }, })), }, ], }; return (