- feedData.ts 聚合首页/板块/帖子详情数据,缺失内容 throw render(404) - Go 侧 spa_meta/seo 的 head 生成逻辑移植到 src/ssr/head.ts - _error 页复用站点壳渲染 404,+data 从 abortReason 恢复壳层数据 - linkedom 模拟服务端 DOM,DOMPurify 封装为 SSR 透传的 sanitizeHtml - 新增 /api/home-boot 聚合端点(handler/home_boot.go)供 SSR 冷启动灌缓存
25 lines
721 B
TypeScript
25 lines
721 B
TypeScript
import type { PageContextServer } from 'vike/types';
|
||
import type { FeedData } from '../../src/ssr/feedData';
|
||
|
||
export { data };
|
||
|
||
type NotFoundAbortReason = {
|
||
head?: FeedData['head'];
|
||
boot?: FeedData['boot'];
|
||
};
|
||
|
||
/**
|
||
* 错误页取数:feed +data 未找到(帖子/板块)时 throw render(404, { head, boot }),
|
||
* 壳层数据经 abortReason 带过来,保证 404 页也渲染完整站点壳与 noindex head。
|
||
*/
|
||
async function data(pageContext: PageContextServer): Promise<FeedData> {
|
||
if (!import.meta.env.SSR) return { kind: 'notfound' };
|
||
|
||
const reason = pageContext.abortReason as NotFoundAbortReason | undefined;
|
||
return {
|
||
kind: 'notfound',
|
||
head: reason?.head,
|
||
boot: reason?.boot,
|
||
};
|
||
}
|