隐私与条款配置
配置法律页面开关、条目映射与自定义法律文案入口。
法律模块负责渲染 Privacy(隐私政策)、Terms(服务条款)、Behavior(社区规范)等页面,由配置决定哪些条目展示。内容可来自 Content Collections 的默认模板,也可通过自定义函数完全接管。
作用与入口
src/app/(landing-page)/[locale]/(cms)/legal/[...path]/page.tsx
src/config/custom-common.ts
src/config/custom-legal.ts
content/legal
| 文件 | 职责 |
|---|---|
legal/[...path]/page.tsx | 法律页面路由与 config.ui.legal.enabled 校验 |
custom-common.ts | 页脚法律链接组装,基于 allowMap |
custom-legal.ts | 自定义法律文案开关与内容函数 |
content/legal | Content Collections 中的法律 MDX 源文件 |
快速改动路径
先用 config.ui.legal.enabled 与 allowMap 控制页面开关和可见条目。
再在 config.i18n.locales.*.footerConfig.legal 维护中英文页脚文案。
需要自定义法律文案时,在 custom-legal.ts 开启 useLegalCustom* 并提供内容函数。
// src/config/index.ts
ui: {
legal: {
enabled: true,
allowMap: [
{ type: "privacy", enabled: true },
{ type: "terms", enabled: true },
{ type: "behavior", enabled: false },
],
},
}// src/config/index.ts
i18n: {
locales: {
zh: {
footerConfig: {
legal: {
privacy: "隐私政策",
terms: "服务条款",
behavior: "社区规范",
},
},
},
en: {
footerConfig: {
legal: {
privacy: "Privacy",
terms: "Terms",
behavior: "Community",
},
},
},
},
}默认渲染与自定义渲染
默认情况下,法律页面使用 Content Collections 中的模板内容。若需完全接管文案,可在 src/config/custom-legal.ts 中:
// src/config/custom-legal.ts
export const useLegalCustomPrivacyData = true;
export const useLegalCustomTermsData = false;
export const useLegalCustomBehaviorData = false;
export const legalI18nPrivacyContent: Record<string, (appInfo: AppInfo) => string> = {
zh: (appInfo) => `# 隐私政策\n\n...你的 Markdown 内容...`,
en: (appInfo) => `# Privacy Policy\n\n...`,
};内容函数
内容函数接收 appInfo,返回 Markdown 字符串,便于插入应用名称等动态文案。
底部配置详解
| 配置项 | 代码位置 | 默认值 | 影响 |
|---|---|---|---|
config.ui.legal.enabled | src/config/index.ts | true | 控制 /legal/** 整体是否可访问 |
config.ui.legal.allowMap | src/config/index.ts | privacy/terms 开启,behavior 关闭 | 控制法律页脚链接和可访问的子页面类型 |
config.i18n.locales.*.footerConfig.legal | src/config/index.ts | Privacy/Terms/Community | 页脚法律分组中的显示文案 |
useLegalCustom* 与 legalI18n*Content | src/config/custom-legal.ts | false / 空对象 | 是否启用自定义法律 Markdown 内容 |