export const DEFAULT_OG_IMAGE = '/images/hero.jpg'
/** 浏览器
品牌后缀(首页为完整标题,子页通过 formatPageTitle 拼接) */
export const SITE_BRAND_TITLE: Record<'en' | 'zh', string> = {
en: 'UMedGlobal—Health Without Borders',
zh: '优医—让优质医疗不再因距离与语言遥不可及,帮助更多人以简单有效的方式获得健康。'
}
/** 短品牌名:页头/页脚、og:site_name、JSON-LD 等 */
export const SITE_NAME: Record<'en' | 'zh', string> = {
en: 'UMedGlobal',
zh: '优医'
}
export function formatPageTitle(pagePart: string, locale: 'en' | 'zh'): string {
return `${pagePart} | ${SITE_BRAND_TITLE[locale]}`
}
export type JsonLdNode = Record
export function normalizeSiteUrl(url: string): string {
return url.replace(/\/$/, '')
}
/** 优先使用当前请求的域名,无请求上下文时回退到配置值 */
export function resolveSiteUrl(fallback: string, origin?: string | null): string {
const candidate = origin?.trim()
if (candidate && candidate !== 'null') {
return normalizeSiteUrl(candidate)
}
return normalizeSiteUrl(fallback)
}
export function toAbsoluteUrl(siteUrl: string, pathOrUrl: string): string {
if (pathOrUrl.startsWith('http://') || pathOrUrl.startsWith('https://')) {
return pathOrUrl
}
const base = normalizeSiteUrl(siteUrl)
const path = pathOrUrl.startsWith('/') ? pathOrUrl : `/${pathOrUrl}`
return `${base}${path}`
}
export function buildGlobalJsonLd(
siteUrl: string,
siteName: string,
locale: 'en' | 'zh'
): JsonLdNode[] {
const absoluteSiteUrl = normalizeSiteUrl(siteUrl)
const logoPath = locale === 'zh' ? '/images/logo-zh.png' : '/images/logo-en.png'
return [
{
'@type': 'MedicalBusiness',
'@id': `${absoluteSiteUrl}/#organization`,
name: siteName,
alternateName: locale === 'zh' ? 'UMedGlobal' : '优医',
url: absoluteSiteUrl,
logo: toAbsoluteUrl(absoluteSiteUrl, logoPath),
image: toAbsoluteUrl(absoluteSiteUrl, DEFAULT_OG_IMAGE),
description:
locale === 'zh'
? '优医是位于广州的专业医疗信息咨询机构,为国际患者对接中国三甲及 JCI 认证医院,提供体检、专科诊疗、二次诊疗意见、签证与出行协调服务。'
: 'UMedGlobal is a Guangzhou-based medical concierge connecting international patients to JCI-accredited and Grade 3A hospitals in China for health screenings, specialist care, second opinions, and visa coordination.',
address: {
'@type': 'PostalAddress',
addressLocality: 'Guangzhou',
addressRegion: 'Guangdong',
addressCountry: 'CN'
},
areaServed: 'Worldwide',
email: 'partners@umedglobal.com'
},
{
'@type': 'WebSite',
'@id': `${absoluteSiteUrl}/#website`,
url: absoluteSiteUrl,
name: siteName,
publisher: { '@id': `${absoluteSiteUrl}/#organization` },
inLanguage: locale === 'zh' ? 'zh-CN' : 'en'
}
]
}
export function wrapJsonLdGraph(nodes: JsonLdNode[]): JsonLdNode {
return {
'@context': 'https://schema.org',
'@graph': nodes
}
}