import { notFound } from 'next/navigation'; import ReactMarkdown from 'react-markdown'; import remarkGfm from 'remark-gfm'; import { getTranslations, Locale, getNavigationPaths } from '@/lib/i18n'; import { generateMetadata as generateSEOMetadata } from '@/lib/seo'; import { getNewsArticle, getAvailableLocalesForArticle, checkArticleExists } from '@/lib/markdown'; import Layout from '@/components/Layout'; import LanguageSwitcher from '@/components/LanguageSwitcher'; import Link from 'next/link'; interface NewsDetailPageProps { params: { locale: Locale; id: string; }; } export async function generateStaticParams() { const locales = ['zh-CN', 'zh-TW', 'en']; const articles = ['ai-transformation-2024', 'cloud-security-best-practices', 'company-expansion-2024']; const params = []; for (const locale of locales) { for (const id of articles) { params.push({ locale, id }); } } return params; } export async function generateMetadata({ params }: NewsDetailPageProps) { const { locale, id } = params; // Check if article exists if (!checkArticleExists(id, locale)) { return { title: 'Article Not Found', description: 'The requested article could not be found.', }; } const article = await getNewsArticle(id, locale); if (!article) { return { title: 'Article Not Found', description: 'The requested article could not be found.', }; } return { title: article.title, description: article.excerpt, openGraph: { title: article.title, description: article.excerpt, type: 'article', publishedTime: article.date, authors: [article.author], tags: article.tags, }, }; } export default async function NewsDetailPage({ params }: NewsDetailPageProps) { const { locale, id } = params; // Check if article exists in the requested locale if (!checkArticleExists(id, locale)) { notFound(); } const article = await getNewsArticle(id, locale); if (!article) { notFound(); } const [common, availableLocales] = await Promise.all([ getTranslations(locale, 'common'), getAvailableLocalesForArticle(id), ]); const navigationPaths = getNavigationPaths(locale); const navigation = [ { name: common.navigation.home, href: navigationPaths.find((p) => p.key === 'home')?.path || '/', }, { name: common.navigation.products, href: navigationPaths.find((p) => p.key === 'products')?.path || '/products', }, { name: common.navigation.news, href: navigationPaths.find((p) => p.key === 'news')?.path || '/news', }, { name: common.navigation.support, href: navigationPaths.find((p) => p.key === 'support')?.path || '/support', }, { name: common.navigation.about, href: navigationPaths.find((p) => p.key === 'about')?.path || '/about', }, ]; return ( {/* Breadcrumb */}
{/* Language Switcher */}
{locale === 'en' ? 'Available in:' : locale === 'zh-TW' ? '可用語言:' : '可用语言:'}
{/* Back to News */} p.key === 'news')?.path || '/news'} className="text-sm text-blue-600 hover:text-blue-800 flex items-center space-x-1" data-oid="eatue3o" > {locale === 'en' ? 'Back to News' : locale === 'zh-TW' ? '返回新聞' : '返回新闻'}
{/* Article Header */}
{article.category} {article.featured && ( {locale === 'en' ? 'Featured' : locale === 'zh-TW' ? '精選' : '精选'} )}

{article.title}

{article.date}
{article.author}
{article.readTime}

{article.excerpt}

{/* Tags */} {article.tags.length > 0 && (
{article.tags.map((tag) => ( #{tag} ))}
)}
{/* Article Content */}
(

{children}

), h2: ({ children }) => (

{children}

), h3: ({ children }) => (

{children}

), p: ({ children }) => (

{children}

), ul: ({ children }) => (
    {children}
), ol: ({ children }) => (
    {children}
), li: ({ children }) => (
  • {children}
  • ), blockquote: ({ children }) => (
    {children}
    ), code: ({ children }) => ( {children} ), pre: ({ children }) => (
                                            {children}
                                        
    ), }} data-oid="gwxptyo" > {article.content}
    {/* Article Footer */}

    {locale === 'en' ? 'Published on' : locale === 'zh-TW' ? '發布於' : '发布于'}{' '} {article.date}

    {locale === 'en' ? 'By' : locale === 'zh-TW' ? '作者:' : '作者:'}{' '} {article.author}

    ); }