'use client'; import { Locale } from '@/lib/i18n'; import { getSEOData, SEOData } from '@/lib/seo'; import { useEffect, useState } from 'react'; interface SEOPreviewProps { locale: Locale; page: string; className?: string; } export default function SEOPreview({ locale, page, className = '' }: SEOPreviewProps) { const [seoData, setSeoData] = useState(null); const [loading, setLoading] = useState(true); useEffect(() => { const loadSEOData = async () => { try { setLoading(true); const data = await getSEOData(locale, page); setSeoData(data); } catch (error) { console.error('Failed to load SEO data:', error); } finally { setLoading(false); } }; loadSEOData(); }, [locale, page]); if (loading) { return (
); } if (!seoData) { return null; } const baseUrl = 'https://haoaws.com'; const currentUrl = `${baseUrl}${locale === 'zh-CN' ? '' : `/${locale}`}${page === 'home' ? '' : `/${page}`}`; return (

{locale === 'zh-CN' ? '搜索引擎预览' : locale === 'zh-TW' ? '搜尋引擎預覽' : 'Search Engine Preview'}

{/* Google Search Result Preview */}
{currentUrl}

{seoData.title}

{seoData.description}

{/* Social Media Preview */}

{locale === 'zh-CN' ? '社交媒体预览' : locale === 'zh-TW' ? '社群媒體預覽' : 'Social Media Preview'}

{locale === 'zh-CN' ? '预览图片' : locale === 'zh-TW' ? '預覽圖片' : 'Preview Image'}
{seoData.title}

{seoData.description}

{currentUrl}
); }