/** * 动态(news)单一事实源。 * * 列表页、详情页、首页 HomeUpdates 一律引用本模块,杜绝三处重复。 * 标题/摘要/正文属于本地化文案,按 slug 存放在 i18n(news.items..*), * 本模块只保存与语言无关的结构化元数据。 */ export interface NewsItem { slug: string category: 'insights' | 'projects' | 'announcements' /** 分类徽章 tailwind 类(静态字符串,Tailwind 扫描 ./app/** 可命中) */ badge: string date: string readTime: string author: string image: string } export const newsItems: NewsItem[] = [ { slug: 'design-trends-2026', category: 'insights', badge: 'bg-purple-100 text-purple-700', date: '2026-05-28', readTime: '5', author: 'ArcticNewOne', image: 'https://picsum.photos/id/1/800/500', }, { slug: 'forma-digital-launch', category: 'projects', badge: 'bg-blue-100 text-blue-700', date: '2026-05-15', readTime: '3', author: 'ArcticNewOne', image: 'https://picsum.photos/id/201/800/500', }, { slug: 'studio-expansion', category: 'announcements', badge: 'bg-green-100 text-green-700', date: '2026-05-10', readTime: '2', author: 'ArcticNewOne', image: 'https://picsum.photos/id/164/800/500', }, { slug: 'ux-research-methods', category: 'insights', badge: 'bg-purple-100 text-purple-700', date: '2026-04-28', readTime: '7', author: 'ArcticNewOne', image: 'https://picsum.photos/id/180/800/500', }, { slug: 'bold-moves-case-study', category: 'projects', badge: 'bg-blue-100 text-blue-700', date: '2026-04-20', readTime: '6', author: 'ArcticNewOne', image: 'https://picsum.photos/id/119/800/500', }, { slug: 'new-tools-integration', category: 'announcements', badge: 'bg-green-100 text-green-700', date: '2026-04-12', readTime: '4', author: 'ArcticNewOne', image: 'https://picsum.photos/id/326/800/500', }, ] export const newsBySlug: Record = Object.fromEntries( newsItems.map((item) => [item.slug, item]), ) export function getNewsCategories(): Array { return ['insights', 'projects', 'announcements'] } /** 显示用的日期(本地化格式化在组件内完成) */ export function formatNewsDate(date: string, locale: string): string { const d = new Date(`${date}T00:00:00`) if (Number.isNaN(d.getTime())) return date return new Intl.DateTimeFormat(locale === 'zh' ? 'zh-CN' : 'en-US', { year: 'numeric', month: 'long', day: 'numeric', }).format(d) } /** 显示用的阅读时长(本地化文案在 i18n,数字在此) */ export function newsReadTime(item: NewsItem): string { return item.readTime }