Files
arcticnewone/app/data/news.ts
T
virtheart 5c3f3bca63 feat: 全量落地后端与功能闭环
- 真实后端(server/):SQLite 存储 + scrypt 会话鉴权 + SMTP 邮件
  - auth 注册/登录/登出/me/资料更新
  - contact 联系表单(落库+邮件)、newsletter 订阅(去重)
  - favorites 作品收藏、comments 新闻评论、account 管理收件箱
- 用户系统 UI:个人中心 /account(资料/收藏/评论/管理员面板)、
  收藏按钮、评论组件、登录/注册弹窗接真实 API(useApiError 错误映射)
- 内容单点事实源:app/data/news|work 消除三处重复,页面全部引用
- 修复断链:首页动态/作品卡可点击、分享按钮真实动作、移除 # 死链、
  语言切换器、社交链接统一 siteConfig
- SEO:动态 sitemap/robots、JSON-LD、脚本生成真实 og-image.png
- 列表增强:搜索 + 加载更多
- 部署自动化:build-and-push.sh 支持 git tag 版本化镜像;
  deploy.sh 一条命令构建推送+注入 Secret/ConfigMap+kubectl 滚动升级;
  deployment 挂 PVC 持久化;Dockerfile 支持 better-sqlite3 原生编译
- 组件注册去目录前缀,修复 AppLoader/AnimatedButton 等未渲染问题
2026-08-06 15:08:34 +08:00

99 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 动态(news)单一事实源。
*
* 列表页、详情页、首页 HomeUpdates 一律引用本模块,杜绝三处重复。
* 标题/摘要/正文属于本地化文案,按 slug 存放在 i18n(news.items.<slug>.*),
* 本模块只保存与语言无关的结构化元数据。
*/
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<string, NewsItem> = Object.fromEntries(
newsItems.map((item) => [item.slug, item]),
)
export function getNewsCategories(): Array<NewsItem['category']> {
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
}