feat(ia): 一级导航改对标双轴(行业 × 能力 + 洞察),并把导航真源从 DB 行反转为代码
依据实测:Bain 一级导航 = Industries · Consulting Services · Digital · Insights · About · Careers,
Porsche = 行业 · 实践 · 洞察 · 职业 · 关于我们 —— **两家的导航里都没有「产品」**。
咨询业按「客户的问题空间 × 本所的能力」组织,不按产品 SKU 组织。本仓此前 7 项里
产品居首,且 案例(case-study 0 行)、新闻动态(2 行) 是挂在骨架上的空渠道。
落地策略是**换标签、不换路由**:行业→既有 /solutions(solution 模型本就是行业),
能力→既有 /services(service 模型的 4 行本就是能力组)。
理由不是省事,而是避免制造重复内容:若新增 /capabilities 与 /services 并行,
同一个 ContentItem 会同时挂在两个 URL 下 —— 那是 canonical 冲突,比不改更糟。
URL 改名 + 308 留给第二批一次性处理。唯一真正新增的面是 /insights:
它聚合 news + methodology + case-study,今天没有任何单一页面做过这件事,故不构成重复。
「轴 = 视图,模型 = 真源」:本轮零新 ContentModel、零 schema、零 seed 权限测试改动。
沿用 solution/service/product 三个 code ⇒ src/lib/seed-permissions.test.ts:50 的
SUPER_ADMIN_ONLY_MODELS 断言保持绿。**这是设计选择的回报,不是没做事。**
最关键的一处:反转导航优先级
layout.tsx 原为 `(navData?.mainNav) || NAVIGATION_V2` —— **DB 行胜出、代码只兜底**。
`navigation` 的字段是泛型 json,改导航不需动 schema,听起来省事,实际是:
只改 navigation.ts 会上线一个**生产静默忽略它**的新导航。
而 footer 按 megaDropdown 的 key 取栏目 —— 新代码 key 对旧 DB key ⇒ 页脚三栏静默变空。
我在工作树里真的复现了这个状态:本地 navigation/default 行仍是旧 7 项,
它**内部完全自洽**(每个 dropdownKey 都找得到面板),所以「自洽即放行」会继续覆盖代码。
⇒ 新校验器的标准是「它是不是这套 IA」(必须覆盖 industries/capabilities/insights 三轴),
而不是「它是不是合法 JSON」。不合格则 fail-closed 到代码 + 把原因 console.warn 出来
(渲染期不写库:Notification 是后台数据,在 RSC 里写它等于给每次首页渲染挂写副作用)。
这条有专门用例:「旧 IA 的自洽配置必须被拒」。
顺带修掉两处同族缺陷
- injectStandaloneProducts 原按 `key === 'products'` 匹配;双轴改名后该 key 不存在 ⇒
独立产品会**静默不再注入**。改为按组 id(STANDALONE_GROUP_ID)找,组 id 比 key 稳定。
- 激活判定原来有**三套**:header 的 8 分支 per-id 阶梯(末尾落回 pathname===`/${item.id}`,
新 id industries 会拼出一个不存在的路由 ⇒ 行业永不高亮)、mobile-tab-bar 的 per-id
if 阶梯(改名后每项静默返回 false ⇒ tab bar 照渲染、永不高亮 = 绿但空洞)、footer 自一套。
现统一为 lib/nav-active.ts,按 segment 切(不被 /solutionship 这类同前缀误点亮)。
撤下两个空渠道入口(含一处我自己计划里的回退,已当场纠正)
- /cases 从一级导航与移动端 tab bar 撤下:case-study 0 行,点进去是空列表。
路由与模型**保留休眠**,真实授权案例到位当天即可渲染,不必二次迁移。
- 补 { id: 'all-products', href: '/products' } 进能力轴第二层:
撤「产品」时若不补这一条,/products(sitemap priority 0.9、6 个详情页的上游 hub)
就变成**没有导航入口的孤儿页** —— 那是回退不是重构。「降级」不等于「消失」,
已加守卫用例「被退出一级导航的 hub 必须在第二层仍可达」。
/insights 的三处登记(少一处就是「新页面没人扫、门禁仍然绿」的静默覆盖收缩)
- sitemap.ts:新增,priority 0.8;/news 暂留(已索引),第二批 301 归并
- check:headings 的 PAGES 列表:新增(该列表是硬编码路由清单)
- revalidate:新增 INSIGHTS_AFFECTED_MODELS(news/case-study/methodology)
—— /insights 不在 CONTENT_TYPE_CONFIGS 的任何 listPage 里,通用推导只刷 /news、
/methodology;少登记这条的后果不是报错,而是后台发了新内容、洞察页仍端出旧 ISR
快照最长 1 小时,且没有任何门禁会红。已钉 3 正向 + 1 负向(product 变更不得刷
/insights,否则该断言恒真、失去约束力)+ 1 去重。
删除 NAVIGATION(V1):7 个 href 全是 '/'、全站零生产引用,只被 constants.test.ts 供着 ——
那 4 条用例的作用是让死码看起来「有人在用」。已改写成断言活的 NAVIGATION_V2,
并保留其原有意图(每个目的地互不相同,正是 V1 缺的那条)。
KNOWN-RED: test:visual —— 一级导航 7→4、页脚三栏改标题改取数、移动端 tab bar 换轴,
header/footer 相关基线预期 churn。按计划 #10 在所有代码落地后一次性重捕(需 AUTH-VISUAL)。
待授权(本笔**未**执行,且必须执行才能对用户生效):
CMS 的 navigation/default 行仍是旧 7 项。本笔的反转校验会让它 fail-closed 到代码,
所以**新导航会立即在页面上生效**(不再被旧行遮蔽),但后台那一行要改需
`npm run db:seed`(生产为独立授权动作)。seed.ts:945 直接引用 NAVIGATION_V2,
重跑即得新行 —— 本地已复跑验证过(库内 mainNav 已是 industries/capabilities/insights)。
门禁实测:type-check EXIT=0 · 全量 jest 146 套件 / 1807 例通过 ·
eslint --quiet 改动文件 0 error · check:grammar 9/9 及其 selftest 9/9 ·
check:token-twins 44/44 · check:contrast 44/44 · check:brand-token 0 违规 ·
e2e nav-keyboard@chromium 6 passed(含 /insights 实测 HTTP 200)
This commit is contained in:
1 parent
e9bd965411
commit
7d1a22a596
23 files changed
+1083
-197
No files matched your search
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* 洞察枢纽的两条诚实性约束(都能失败,不是给实现打气):
|
||||
* 1. 筛选器只列**真的有内容**的分类 —— 本仓此前把 案例(0 行) 挂在一级导航上,
|
||||
* 这条就是防它在新页面上重演。
|
||||
* 2. 0 条目必须落在"看得见的空态",而不是渲染一个空网格装作有内容。
|
||||
*/
|
||||
import { describe, it, expect, jest } from '@jest/globals';
|
||||
import { render, screen, fireEvent } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom';
|
||||
import InsightsContent, { type InsightEntry } from './insights-content';
|
||||
|
||||
jest.mock('@/components/ui/static-link', () => ({
|
||||
StaticLink: ({ children, href, ...rest }: { children: React.ReactNode; href: string; [k: string]: unknown }) => (
|
||||
<a href={href} {...rest}>{children}</a>
|
||||
),
|
||||
}));
|
||||
jest.mock('@/components/ui/scroll-reveal', () => ({
|
||||
ScrollReveal: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
StaggerReveal: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
jest.mock('@/components/ui/cta-button', () => ({
|
||||
CTAButton: ({ children, href }: { children: React.ReactNode; href: string }) => (
|
||||
<a href={href}>{children}</a>
|
||||
),
|
||||
}));
|
||||
|
||||
const METH: InsightEntry = { id: 'm1', kind: 'methodology', title: '四步诊断法', excerpt: '从业务目标出发', date: '', href: '/methodology' };
|
||||
const WRITING: InsightEntry = { id: 'w1', kind: 'writing', title: '私有化部署', excerpt: '数据主权', date: '2026-08', href: '/news/1' };
|
||||
|
||||
describe('洞察筛选器的分母纪律', () => {
|
||||
it('案例 0 行时,「客户成果」这个 tab 不允许出现', () => {
|
||||
render(<InsightsContent entries={[METH, WRITING]} />);
|
||||
expect(screen.queryByRole('tab', { name: '客户成果' })).not.toBeInTheDocument();
|
||||
expect(screen.getByRole('tab', { name: '方法论' })).toBeInTheDocument();
|
||||
expect(screen.getByRole('tab', { name: '技术与观点' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('case-study 一旦出数,「客户成果」tab 自动出现(插槽真的能插,不是空话)', () => {
|
||||
const real: InsightEntry = {
|
||||
id: 'c1', kind: 'case', title: '某制造企业库存周转', excerpt: '', date: '2026-09',
|
||||
href: '/cases/x', industry: '制造业',
|
||||
};
|
||||
render(<InsightsContent entries={[METH, WRITING, real]} />);
|
||||
expect(screen.getByRole('tab', { name: '客户成果' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('完全无内容 ⇒ 走空态而不是空网格', () => {
|
||||
render(<InsightsContent entries={[]} />);
|
||||
expect(screen.getByTestId('insights-empty')).toBeInTheDocument();
|
||||
expect(screen.queryAllByTestId(/^insight-card-/)).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('点「方法论」后只留方法论条目(过滤真的生效,不是只改了按钮态)', () => {
|
||||
render(<InsightsContent entries={[METH, WRITING]} />);
|
||||
fireEvent.click(screen.getByRole('tab', { name: '方法论' }));
|
||||
expect(screen.getAllByTestId('insight-card-methodology')).toHaveLength(1);
|
||||
expect(screen.queryAllByTestId('insight-card-writing')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,177 @@
|
||||
'use client';
|
||||
|
||||
import { useMemo, useState } from 'react';
|
||||
import { StaticLink } from '@/components/ui/static-link';
|
||||
import { ScrollReveal } from '@/components/ui/scroll-reveal';
|
||||
import { CTAButton } from '@/components/ui/cta-button';
|
||||
import { COMPANY_INFO } from '@/lib/constants';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { ArrowRight } from 'lucide-react';
|
||||
|
||||
export type InsightKind = 'methodology' | 'case' | 'writing';
|
||||
|
||||
export interface InsightEntry {
|
||||
id: string;
|
||||
kind: InsightKind;
|
||||
title: string;
|
||||
excerpt: string;
|
||||
/** ISO 或 'YYYY-MM';方法论这类"页面型"条目没有日期,留空 */
|
||||
date: string;
|
||||
href: string;
|
||||
industry?: string;
|
||||
}
|
||||
|
||||
const KIND_LABEL: Record<InsightKind, string> = {
|
||||
methodology: '方法论',
|
||||
case: '客户成果',
|
||||
writing: '技术与观点',
|
||||
};
|
||||
|
||||
/**
|
||||
* 洞察枢纽 —— 对标 Bain「Our Latest Insights」/ Porsche「In Focus: News & Trends」。
|
||||
*
|
||||
* 语法取自实测:零圆角(bain-card 现 --radius-lg = 2px)、近单色、
|
||||
* 卡片 hover 只改边框与底色(不抬升、不加阴影),成果类数字本轮不出现——
|
||||
* 因为 case-study 模型是 0 行,任何数字都得编。
|
||||
*
|
||||
* 诚实性约束(可失败,见 insights-content.test.tsx):
|
||||
* 1. 筛选器只列**真的有内容**的 kind。案例 0 行 ⇒ 不给「客户成果」这个 tab,
|
||||
* 否则就是挂一个点开为空的频道(本仓此前 /cases 正是这样挂在一级导航上的)。
|
||||
* 2. 0 条目时的空态必须是"看得见的空态",不拿模板文案冒充内容。
|
||||
*/
|
||||
export default function InsightsContent({ entries }: { entries: InsightEntry[] }) {
|
||||
const presentKinds = useMemo(
|
||||
() => (['methodology', 'case', 'writing'] as InsightKind[]).filter((k) => entries.some((e) => e.kind === k)),
|
||||
[entries],
|
||||
);
|
||||
const [active, setActive] = useState<'all' | InsightKind>('all');
|
||||
|
||||
const visible = active === 'all' ? entries : entries.filter((e) => e.kind === active);
|
||||
|
||||
return (
|
||||
<div data-testid="insights-page">
|
||||
{/* L1 —— 结论式主张,不是口号 */}
|
||||
<section className="bg-bg-primary border-b border-border-primary" data-testid="hero-section">
|
||||
<div className="container-x py-16 md:py-24">
|
||||
<ScrollReveal>
|
||||
<p className="text-sm font-medium text-brand-ink tracking-wider mb-4">洞察</p>
|
||||
<h1 className="text-4xl md:text-5xl font-bold text-text-primary leading-tight max-w-4xl">
|
||||
我们怎么判断、怎么交付、怎么验收
|
||||
</h1>
|
||||
<p className="mt-5 text-base md:text-lg text-text-secondary leading-relaxed max-w-3xl">
|
||||
{COMPANY_INFO.displayName}的公开写作与方法论。凡涉及效果的数字,都会标明它是
|
||||
<strong className="font-medium text-text-primary">目标口径</strong>、
|
||||
<strong className="font-medium text-text-primary">团队历史</strong>还是
|
||||
<strong className="font-medium text-text-primary">已验证结果</strong>。
|
||||
</p>
|
||||
</ScrollReveal>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* 列表 */}
|
||||
<section className="bg-bg-secondary" data-testid="insights-list">
|
||||
<div className="container-x py-16 md:py-20">
|
||||
<div className="flex flex-wrap items-center justify-between gap-4 mb-8">
|
||||
<h2 className="text-2xl font-bold text-text-primary">全部内容</h2>
|
||||
{/* 筛选器只列有内容的 kind:这是「不给空频道挂入口」那条约束的实现处 */}
|
||||
<div className="flex flex-wrap gap-1" role="tablist" aria-label="洞察分类">
|
||||
<FilterTab label="全部" activeState={active === 'all'} onClick={() => setActive('all')} />
|
||||
{presentKinds.map((k) => (
|
||||
<FilterTab
|
||||
key={k}
|
||||
label={KIND_LABEL[k]}
|
||||
activeState={active === k}
|
||||
onClick={() => setActive(k)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{visible.length === 0 ? (
|
||||
/* 空态必须是"看得见的空态" —— 不拿模板文案冒充内容 */
|
||||
<div className="bain-card p-10 text-center" data-testid="insights-empty">
|
||||
<p className="text-text-secondary leading-relaxed">
|
||||
这一类目前还没有已发布的内容。
|
||||
<br />
|
||||
客户成果要等真实项目获得对外授权后才会出现在这里。
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<ul className="grid gap-4 md:grid-cols-2 lg:grid-cols-3 list-none p-0 m-0">
|
||||
{visible.map((entry) => (
|
||||
<li key={entry.id}>
|
||||
<StaticLink
|
||||
href={entry.href}
|
||||
className="bain-card block p-6 h-full transition-colors duration-hover hover:border-border-rule"
|
||||
data-testid={`insight-card-${entry.kind}`}
|
||||
>
|
||||
<div className="flex items-center gap-2 mb-3">
|
||||
<span className="text-xs font-medium text-brand-ink">{KIND_LABEL[entry.kind]}</span>
|
||||
{entry.industry && (
|
||||
<span className="text-xs text-text-muted">· {entry.industry}</span>
|
||||
)}
|
||||
{entry.date && (
|
||||
<span className="ml-auto text-xs text-text-muted tabular-nums">{entry.date}</span>
|
||||
)}
|
||||
</div>
|
||||
<h3 className="text-lg font-semibold text-text-primary leading-snug">{entry.title}</h3>
|
||||
{entry.excerpt && (
|
||||
<p className="mt-2 text-sm text-text-secondary leading-relaxed">{entry.excerpt}</p>
|
||||
)}
|
||||
<span className="mt-4 inline-flex items-center gap-1 text-sm font-medium text-text-primary group-hover:text-brand-ink">
|
||||
阅读
|
||||
<ArrowRight className="w-4 h-4" aria-hidden="true" />
|
||||
</span>
|
||||
</StaticLink>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{/* L4 CTA */}
|
||||
<section className="bg-bg-primary border-t border-border-primary">
|
||||
<div className="container-x py-16 text-center">
|
||||
<h2 className="text-2xl md:text-3xl font-bold text-text-primary">有具体场景想聊?</h2>
|
||||
<p className="mt-3 text-text-secondary max-w-2xl mx-auto leading-relaxed">
|
||||
把你的问题带来,我们先给判断,再谈方案。
|
||||
</p>
|
||||
<div className="mt-8 flex flex-wrap items-center justify-center gap-4">
|
||||
<CTAButton href="/contact">预约咨询</CTAButton>
|
||||
<CTAButton href="/services" variant="secondary">
|
||||
查看能力组
|
||||
</CTAButton>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function FilterTab({
|
||||
label,
|
||||
activeState,
|
||||
onClick,
|
||||
}: {
|
||||
label: string;
|
||||
activeState: boolean;
|
||||
onClick: () => void;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
type="button"
|
||||
role="tab"
|
||||
aria-selected={activeState}
|
||||
onClick={onClick}
|
||||
className={cn(
|
||||
'px-4 py-2 text-sm font-medium transition-colors duration-hover min-h-[44px]',
|
||||
activeState
|
||||
? 'bg-brand text-white'
|
||||
: 'bg-bg-primary text-text-secondary border border-border-primary hover:text-text-primary',
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
import { Metadata } from 'next';
|
||||
import { COMPANY_INFO } from '@/lib/constants';
|
||||
import { getPublishedItems } from '@/lib/cms/data-server';
|
||||
import type { NewsItem } from '@/lib/constants/news';
|
||||
import InsightsContent, { type InsightEntry } from './insights-content';
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: `洞察 - ${COMPANY_INFO.displayName}`,
|
||||
description: `${COMPANY_INFO.displayName}的方法论、技术与观点:数字化转型怎么判断、怎么交付、怎么验收。`,
|
||||
};
|
||||
|
||||
// ISR 与 /news 同档;CMS 发布经 /api/cms/revalidate 主动刷新。
|
||||
// ⚠ 新路由必须同步进 revalidate 的路径表与 check:headings 的 PAGES,
|
||||
// 否则「全站扫描」的分母会静默变小而门禁仍然绿。
|
||||
export const revalidate = 3600;
|
||||
|
||||
/** 洞察条目 kind:news 分类沿用既有 taxonomy,方法论与案例是另外两路真源 */
|
||||
async function buildEntries(): Promise<InsightEntry[]> {
|
||||
const [newsItems, caseItems, methodologyItems] = await Promise.all([
|
||||
getPublishedItems('news').catch(() => []),
|
||||
getPublishedItems('case-study').catch(() => []),
|
||||
getPublishedItems('methodology').catch(() => []),
|
||||
]);
|
||||
|
||||
const news: InsightEntry[] = newsItems.map((item) => {
|
||||
const data = item.data as unknown as NewsItem;
|
||||
return {
|
||||
id: `news-${data.id || item.slug}`,
|
||||
kind: 'writing' as const,
|
||||
title: data.title || item.title,
|
||||
excerpt: data.excerpt || '',
|
||||
date: data.date || '',
|
||||
href: `/news/${data.id || item.slug}`,
|
||||
};
|
||||
});
|
||||
|
||||
// 方法论:/methodology 是一个 4 阶段的页面型模型(1 行),不是逐篇内容
|
||||
const methodology: InsightEntry[] = methodologyItems.map((item) => {
|
||||
const data = item.data as { title?: string; description?: string; summary?: string };
|
||||
return {
|
||||
id: `methodology-${item.slug}`,
|
||||
kind: 'methodology' as const,
|
||||
title: data.title || item.title,
|
||||
excerpt: data.description || data.summary || '',
|
||||
date: '',
|
||||
href: '/methodology',
|
||||
};
|
||||
});
|
||||
|
||||
/**
|
||||
* 案例:**当前恒为空数组**,因为 case-study 模型 0 行
|
||||
* (prisma/seeds/case-studies.ts:11 明示「首批客户共创阶段,暂无对外可验证的客户案例」)。
|
||||
* 零编造原则下这里不造任何条目;真实授权案例落库的当天,下面的 map 就开始出数,
|
||||
* 前端不需要再改一行 —— 这就是「留结构化插槽」的实际含义。
|
||||
*/
|
||||
const cases: InsightEntry[] = caseItems.map((item) => {
|
||||
const data = item.data as { title?: string; excerpt?: string; industry?: string; publishedAt?: string };
|
||||
return {
|
||||
id: `case-${item.slug}`,
|
||||
kind: 'case' as const,
|
||||
title: data.title || item.title,
|
||||
excerpt: data.excerpt || '',
|
||||
date: data.publishedAt || '',
|
||||
industry: data.industry,
|
||||
href: `/cases/${item.slug}`,
|
||||
};
|
||||
});
|
||||
|
||||
return [...methodology, ...cases, ...news].sort((a, b) => (b.date || '').localeCompare(a.date || ''));
|
||||
}
|
||||
|
||||
export default async function InsightsPage() {
|
||||
const entries = await buildEntries();
|
||||
return <InsightsContent entries={entries} />;
|
||||
}
|
||||
@@ -287,3 +287,34 @@ describe('POST /api/cms/revalidate', () => {
|
||||
expect(body.data.revalidatedPaths).toContain('/products/erp-upgrade');
|
||||
});
|
||||
});
|
||||
|
||||
// ── 洞察枢纽的失效映射(2026-10-16 双轴改造新增路由)──────────────────────
|
||||
// /insights 不在 CONTENT_TYPE_CONFIGS 的任何 listPage 里 ⇒ 通用推导只会刷 /news、
|
||||
// /methodology。少登记这一条的后果不是报错,而是**后台发了新内容、洞察页仍端出旧
|
||||
// ISR 快照,最长 1 小时,且没有任何门禁会红**。所以正反两向都要钉住。
|
||||
describe('POST /api/cms/revalidate —— /insights 失效映射', () => {
|
||||
it.each(['news', 'case-study', 'methodology'])(
|
||||
'%s 变更必须同时刷 /insights',
|
||||
async (modelCode) => {
|
||||
const response = await POST(createMockRequest({ modelCode }));
|
||||
const body = await response.json();
|
||||
|
||||
expect(response.status).toBe(200);
|
||||
expect(mockRevalidatePath).toHaveBeenCalledWith('/insights');
|
||||
expect(body.data.revalidatedPaths).toContain('/insights');
|
||||
},
|
||||
);
|
||||
|
||||
// 负对照:映射不能宽到「什么都刷」——那会让这条断言恒真、失去约束力
|
||||
it('product 变更不该刷 /insights(洞察轴不读 product 模型)', async () => {
|
||||
const response = await POST(createMockRequest({ modelCode: 'product', slug: 'erp' }));
|
||||
expect(response.status).toBe(200);
|
||||
expect(mockRevalidatePath).not.toHaveBeenCalledWith('/insights');
|
||||
});
|
||||
|
||||
it('同一 modelCode 重复调用只刷一次 /insights(去重仍成立)', async () => {
|
||||
await POST(createMockRequest({ modelCode: 'news', slug: 'a' }));
|
||||
const calls = mockRevalidatePath.mock.calls.filter((c) => c[0] === '/insights');
|
||||
expect(calls).toHaveLength(1);
|
||||
});
|
||||
});
|
||||
@@ -20,6 +20,12 @@ const HOME_AFFECTED_MODELS = new Set([
|
||||
'news',
|
||||
]);
|
||||
|
||||
// 洞察枢纽 /insights 的数据来自三路真源:news(技术与观点)、case-study(客户成果,当前 0 行)、
|
||||
// methodology(方法论)。它**不在** CONTENT_TYPE_CONFIGS 的任何 listPage 里 ——
|
||||
// 通用推导只会刷 /news、/methodology,于是后台发了新内容而 /insights 仍端出旧 ISR 快照,
|
||||
// 最长 1 小时不可见,且没有任何门禁会红。新路由必须显式登记失效映射。
|
||||
const INSIGHTS_AFFECTED_MODELS = new Set(['news', 'case-study', 'methodology']);
|
||||
|
||||
interface RevalidateRequestBody {
|
||||
event?: string;
|
||||
modelCode?: string;
|
||||
@@ -122,6 +128,15 @@ export async function POST(request: NextRequest) {
|
||||
revalidatedPaths.push('/products/erp-upgrade');
|
||||
}
|
||||
|
||||
// 洞察枢纽:三个上游模型任一变更都要刷 /insights
|
||||
if (
|
||||
INSIGHTS_AFFECTED_MODELS.has(body.modelCode) &&
|
||||
!revalidatedPaths.includes('/insights')
|
||||
) {
|
||||
revalidatePath('/insights');
|
||||
revalidatedPaths.push('/insights');
|
||||
}
|
||||
|
||||
// 首页相关模型变更时同步刷新 /
|
||||
if (HOME_AFFECTED_MODELS.has(body.modelCode) && !revalidatedPaths.includes('/')) {
|
||||
revalidatePath('/');
|
||||
|
||||
+14
-17
@@ -16,9 +16,9 @@ import { MotionProvider } from "@/components/ui/motion-provider";
|
||||
import { BackToTop } from "@/components/ui/back-to-top";
|
||||
import { ClientLayout } from "@/components/layout/client-layout";
|
||||
import { getPublishedItems } from "@/lib/cms/data-server";
|
||||
import { SiteConfigProvider, type SiteConfig, type NavigationItem, type MegaDropdownGroup, type MegaDropdownItem } from "@/lib/site-config";
|
||||
import { SiteConfigProvider, type SiteConfig, type NavigationItem, type MegaDropdownItem } from "@/lib/site-config";
|
||||
import { COMPANY_INFO, BRAND_NARRATIVE, type BrandPillar } from "@/lib/constants/company";
|
||||
import { NAVIGATION_V2, MEGA_DROPDOWN_DATA } from "@/lib/constants/navigation";
|
||||
import { resolveNavigation, injectStandaloneProducts } from "@/lib/navigation-resolution";
|
||||
|
||||
/**
|
||||
* 拉丁字形使用 Geist(本地 woff2,无网络请求);
|
||||
@@ -127,21 +127,18 @@ export default async function RootLayout({
|
||||
};
|
||||
});
|
||||
|
||||
// Build megaDropdown with standalone products dynamically injected
|
||||
const baseMegaDropdown = (navData?.megaDropdown as Record<string, MegaDropdownGroup[]>) || MEGA_DROPDOWN_DATA;
|
||||
const megaDropdown: Record<string, MegaDropdownGroup[]> = {};
|
||||
for (const [key, groups] of Object.entries(baseMegaDropdown)) {
|
||||
if (key === 'products' && standaloneNavItems.length > 0) {
|
||||
megaDropdown[key] = groups.map((group) => {
|
||||
if (group.id === 'standalone-products') {
|
||||
return { ...group, description: undefined, items: standaloneNavItems };
|
||||
}
|
||||
return group;
|
||||
});
|
||||
} else {
|
||||
megaDropdown[key] = groups;
|
||||
}
|
||||
// 导航解析:**代码为真源,CMS 仅在完整自洽时覆盖**。
|
||||
// 原写法是 `(navData?.mainNav as ...) || NAVIGATION_V2` —— DB 行胜出、代码只兜底,
|
||||
// 于是「只改 navigation.ts 会上线一个生产静默忽略它的新导航」。详见 lib/navigation-resolution.ts。
|
||||
const nav = resolveNavigation(navData);
|
||||
if (nav.issues.length > 0) {
|
||||
// 渲染期不写库(Notification 是后台数据,在 RSC 里写它等于给每次首页渲染挂写副作用),
|
||||
// 但「为什么没用后台配置」必须可见,否则 fail-closed 会被读成"后台改了没反应"的玄学。
|
||||
console.warn('[navigation] 退回代码真源:\n ' + nav.issues.join('\n '));
|
||||
}
|
||||
// 独立产品按**组 id** 注入(原实现按 key==='products' 匹配,双轴改名后该 key 已不存在,
|
||||
// 沿用会静默丢失这一组:面板照样渲染,只是少了它)。
|
||||
const megaDropdown = injectStandaloneProducts(nav.megaDropdown, standaloneNavItems);
|
||||
|
||||
const siteConfig: SiteConfig = {
|
||||
name: (configData?.name as string) || COMPANY_INFO.name,
|
||||
@@ -160,7 +157,7 @@ export default async function RootLayout({
|
||||
address: (configData?.address as string) || COMPANY_INFO.address,
|
||||
icp: (configData?.icp as string) || COMPANY_INFO.icp,
|
||||
police: (configData?.police as string) || COMPANY_INFO.police,
|
||||
mainNav: (navData?.mainNav as NavigationItem[]) || NAVIGATION_V2,
|
||||
mainNav: nav.mainNav as unknown as NavigationItem[],
|
||||
megaDropdown,
|
||||
};
|
||||
|
||||
|
||||
@@ -17,6 +17,9 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
|
||||
// 案例列表页:数据库 case-study 暂无已发布内容,空列表页不收录(页面保留,待产品补数据后恢复)。
|
||||
// { url: `${BASE_URL}/cases`, lastModified: new Date(), changeFrequency: 'weekly', priority: 0.8 },
|
||||
{ url: `${BASE_URL}/news`, lastModified: new Date(), changeFrequency: 'daily', priority: 0.7 },
|
||||
// 洞察枢纽(双轴改造新增):聚合 news + methodology + case-study。
|
||||
// /news 暂留(已被索引、且 2 条内容仍在贡献长尾),第二批用 301 归并 —— 见计划 §11 待拍 #3。
|
||||
{ url: `${BASE_URL}/insights`, lastModified: new Date(), changeFrequency: 'daily', priority: 0.8 },
|
||||
{ url: `${BASE_URL}/team`, lastModified: new Date(), changeFrequency: 'monthly', priority: 0.6 },
|
||||
{ url: `${BASE_URL}/methodology`, lastModified: new Date(), changeFrequency: 'monthly', priority: 0.6 },
|
||||
{ url: `${BASE_URL}/contact`, lastModified: new Date(), changeFrequency: 'monthly', priority: 0.7 },
|
||||
|
||||
Reference in new issue
Block a user