147 lines
4.4 KiB
TypeScript
147 lines
4.4 KiB
TypeScript
import { Locale } from '@/lib/i18n';
|
|
|
|
interface StructuredDataProps {
|
|
locale: Locale;
|
|
page: string;
|
|
}
|
|
|
|
export default function StructuredData({ locale, page }: StructuredDataProps) {
|
|
const getOrganizationData = () => {
|
|
const names = {
|
|
'zh-CN': '创新科技',
|
|
'zh-TW': '創新科技',
|
|
en: 'Innovation Tech',
|
|
};
|
|
|
|
const descriptions = {
|
|
'zh-CN': '专注于企业数字化转型的科技公司',
|
|
'zh-TW': '專注於企業數位化轉型的科技公司',
|
|
en: 'Technology company focused on enterprise digital transformation',
|
|
};
|
|
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'Organization',
|
|
name: names[locale],
|
|
description: descriptions[locale],
|
|
url: `https://haoaws.com${locale === 'zh-CN' ? '' : `/${locale}`}`,
|
|
logo: 'https://haoaws.com/logo.png',
|
|
contactPoint: {
|
|
'@type': 'ContactPoint',
|
|
telephone: '+86-400-123-4567',
|
|
contactType: 'customer service',
|
|
availableLanguage: ['Chinese', 'English'],
|
|
},
|
|
address: {
|
|
'@type': 'PostalAddress',
|
|
addressCountry: 'CN',
|
|
addressLocality: 'Beijing',
|
|
},
|
|
sameAs: [
|
|
'https://www.linkedin.com/company/haoaws',
|
|
'https://twitter.com/innovation_tech',
|
|
],
|
|
};
|
|
};
|
|
|
|
const getWebsiteData = () => {
|
|
const names = {
|
|
'zh-CN': '创新科技官网',
|
|
'zh-TW': '創新科技官網',
|
|
en: 'Innovation Tech Official Website',
|
|
};
|
|
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'WebSite',
|
|
name: names[locale],
|
|
url: `https://haoaws.com${locale === 'zh-CN' ? '' : `/${locale}`}`,
|
|
potentialAction: {
|
|
'@type': 'SearchAction',
|
|
target: {
|
|
'@type': 'EntryPoint',
|
|
urlTemplate: `https://haoaws.com${locale === 'zh-CN' ? '' : `/${locale}`}/search?q={search_term_string}`,
|
|
},
|
|
'query-input': 'required name=search_term_string',
|
|
},
|
|
};
|
|
};
|
|
|
|
const getBreadcrumbData = () => {
|
|
const pageNames = {
|
|
'zh-CN': {
|
|
home: '首页',
|
|
about: '关于我们',
|
|
products: '产品与服务',
|
|
news: '新闻资讯',
|
|
support: '客户支持',
|
|
},
|
|
'zh-TW': {
|
|
home: '首頁',
|
|
about: '關於我們',
|
|
products: '產品與服務',
|
|
news: '新聞資訊',
|
|
support: '客戶支援',
|
|
},
|
|
en: {
|
|
home: 'Home',
|
|
about: 'About Us',
|
|
products: 'Products & Services',
|
|
news: 'News & Updates',
|
|
support: 'Customer Support',
|
|
},
|
|
};
|
|
|
|
const baseUrl = `https://haoaws.com${locale === 'zh-CN' ? '' : `/${locale}`}`;
|
|
|
|
const breadcrumbList = [
|
|
{
|
|
'@type': 'ListItem',
|
|
position: 1,
|
|
name: pageNames[locale].home,
|
|
item: baseUrl,
|
|
},
|
|
];
|
|
|
|
if (page !== 'home') {
|
|
breadcrumbList.push({
|
|
'@type': 'ListItem',
|
|
position: 2,
|
|
name: pageNames[locale][page as keyof (typeof pageNames)[typeof locale]],
|
|
item: `${baseUrl}${page === 'home' ? '' : `/${page}`}`,
|
|
});
|
|
}
|
|
|
|
return {
|
|
'@context': 'https://schema.org',
|
|
'@type': 'BreadcrumbList',
|
|
itemListElement: breadcrumbList,
|
|
};
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{
|
|
__html: JSON.stringify(getOrganizationData()),
|
|
}}
|
|
/>
|
|
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{
|
|
__html: JSON.stringify(getWebsiteData()),
|
|
}}
|
|
/>
|
|
|
|
<script
|
|
type="application/ld+json"
|
|
dangerouslySetInnerHTML={{
|
|
__html: JSON.stringify(getBreadcrumbData()),
|
|
}}
|
|
/>
|
|
</>
|
|
);
|
|
}
|