完善站点运营设置:分路由管理、登录可见评论、邮件模板内联与关闭注册 SSR。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
40
frontend/lib/publicMetaSnapshot.ts
Normal file
40
frontend/lib/publicMetaSnapshot.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
/** 进程内公开元信息快照:供根 layout 同步 generateMetadata,避免 await 触发标题闪成 localhost */
|
||||
|
||||
export type PublicMetaSnapshot = {
|
||||
site_name: string;
|
||||
site_slogan: string;
|
||||
site_description: string;
|
||||
site_keywords: string[];
|
||||
favicon_url: string;
|
||||
};
|
||||
|
||||
const DEFAULT_SNAP: PublicMetaSnapshot = {
|
||||
site_name: "姜十三论坛",
|
||||
site_slogan: "",
|
||||
site_description: "姜十三论坛 - 技术分享与讨论社区",
|
||||
site_keywords: [],
|
||||
favicon_url: "",
|
||||
};
|
||||
|
||||
let snap: PublicMetaSnapshot = { ...DEFAULT_SNAP };
|
||||
|
||||
export function publishPublicMetaSnapshot(
|
||||
s: Partial<PublicMetaSnapshot> | null | undefined,
|
||||
): void {
|
||||
if (!s) return;
|
||||
const name = typeof s.site_name === "string" ? s.site_name.trim() : "";
|
||||
snap = {
|
||||
site_name: name || DEFAULT_SNAP.site_name,
|
||||
site_slogan: typeof s.site_slogan === "string" ? s.site_slogan.trim() : snap.site_slogan,
|
||||
site_description:
|
||||
typeof s.site_description === "string" && s.site_description.trim()
|
||||
? s.site_description.trim()
|
||||
: snap.site_description,
|
||||
site_keywords: Array.isArray(s.site_keywords) ? s.site_keywords : snap.site_keywords,
|
||||
favicon_url: typeof s.favicon_url === "string" ? s.favicon_url.trim() : snap.favicon_url,
|
||||
};
|
||||
}
|
||||
|
||||
export function peekPublicMetaSnapshot(): PublicMetaSnapshot {
|
||||
return snap;
|
||||
}
|
||||
Reference in New Issue
Block a user