Download frontend/src/components/articles/article-shell.tsx from new-arc/vector: direct link, hf CLI and curl.
- Browser
- Download file 7.95 kB
-
https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/src/components/articles/article-shell.tsx
- Command line
-
hf download hf://spaces/new-arc/vector/frontend/src/components/articles/article-shell.tsx
-
curl -L -o article-shell.tsx https://huggingface.co/spaces/new-arc/vector/resolve/main/frontend/src/components/articles/article-shell.tsx
7.95 kB
| 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 ( | |
| <figure className="not-prose overflow-hidden rounded-lg border bg-zinc-950 text-zinc-100"> | |
| {label ? <figcaption className="border-b border-zinc-800 px-4 py-2 font-mono text-xs text-zinc-400">{label}</figcaption> : null} | |
| <pre className="overflow-x-auto p-4 text-[13px] leading-6"><code className="!bg-transparent !p-0 !text-[13px] !text-zinc-100">{children.trim()}</code></pre> | |
| </figure> | |
| ); | |
| } | |
| /** 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<Record<string, unknown>>; | |
| 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 ( | |
| <main className="min-h-screen bg-background text-foreground"> | |
| <script type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(structuredData).replace(/</g, "\\u003c") }} /> | |
| ); | |
| } | |