Skip to content

Commit 0104deb

Browse files
shiznclaude
andauthored
Use the archive menu on the blog and docs after the shutdown (#3282)
The blog and docs are served by the docs app, which still rendered the live header (Data Explorer, Collections, Trending, search, live event counter), so the menu changed when a visitor clicked Blog or About on the archive pages, and every blog or docs page requested /api/q, which now answers 410. Both apps now take the archive menu from one shared list, and the docs app drops the search box and counter once the site is past the shutdown. The docs search dialog called /api/search, which on ossinsight.io reaches the web app instead of the docs app; it now calls /docs/search. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 7db1183 commit 0104deb

6 files changed

Lines changed: 37 additions & 15 deletions

File tree

‎apps/docs/app/docs/search/route.ts‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import {auditedDocsGet} from '@/lib/route-audit';
2+
import { search } from '@/lib/source';
3+
4+
// The search dialog calls this path: on ossinsight.io only /docs/* and /blog/* are routed to the docs
5+
// app, so /api/search there reaches the web app instead.
6+
export const dynamic = 'force-dynamic';
7+
export const GET = auditedDocsGet('/docs/search', search.GET);

‎apps/docs/app/layout.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export default async function RootLayout({
3636
children: React.ReactNode;
3737
}) {
3838
const nonce = (await headers()).get('x-nonce') ?? undefined;
39+
const archived = isPastSunset() || process.env.OSSINSIGHT_SITE_MODE === 'archive';
3940
return (
4041
<html
4142
lang="en"
@@ -56,6 +57,8 @@ export default async function RootLayout({
5657
<RootProvider
5758
search={{
5859
enabled: true,
60+
// On ossinsight.io only /docs/* and /blog/* reach this app; /api/* goes to the web app.
61+
options: { api: '/docs/search' },
5962
}}
6063
theme={{
6164
nonce,
@@ -66,8 +69,8 @@ export default async function RootLayout({
6669
>
6770
{/* Docs pages render per request, so the banner turns to past tense on the sunset day
6871
without a redeploy. OSSINSIGHT_SITE_MODE=archive forces it, e.g. on a preview. */}
69-
<SunsetBanner app="docs" archived={isPastSunset() || process.env.OSSINSIGHT_SITE_MODE === 'archive'} />
70-
<SharedSiteHeader />
72+
<SunsetBanner app="docs" archived={archived} />
73+
<SharedSiteHeader archived={archived} />
7174
{children}
7275
</RootProvider>
7376
</QueryProvider>
Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
11
'use client';
22

3-
import { SiteHeader, RealtimeSummary, HeaderAnalyzeSelector, createAppHeaderConfig, getCrossAppHref } from '@repo/site-shell';
3+
import { SiteHeader, RealtimeSummary, HeaderAnalyzeSelector, createAppHeaderConfig, createArchiveHeaderItems, getCrossAppHref } from '@repo/site-shell';
44
import { usePathname } from 'next/navigation';
55
import { useCallback } from 'react';
66
import clsx from 'clsx';
77

88
const headerConfig = createAppHeaderConfig('docs');
9+
// After the shutdown: the same menu as the archive pages, without search or the live counter,
10+
// whose data routes answer 410.
11+
const archiveHeaderItems = createArchiveHeaderItems('docs');
912
const webOrigin = getCrossAppHref('docs', 'web', '');
1013
const webApiBase = `${webOrigin}/api/q`;
1114
const ghApiBase = `${webOrigin}`;
1215

13-
export function SharedSiteHeader() {
16+
export function SharedSiteHeader({ archived = false }: { archived?: boolean }) {
1417
const pathname = usePathname();
1518
const isDocsHome = pathname === '/';
1619
const backgroundColor = isDocsHome ? '#212122' : '#1a1a1b';
@@ -22,14 +25,15 @@ export function SharedSiteHeader() {
2225
return (
2326
<SiteHeader
2427
{...headerConfig}
28+
{...(archived ? { items: archiveHeaderItems } : {})}
2529
className={clsx(
2630
'border-b-0 shadow-none',
2731
isDocsHome ? 'bg-[#212122]' : 'bg-[#1a1a1b]',
2832
)}
2933
style={{ backgroundColor }}
30-
searchSlot={<HeaderAnalyzeSelector apiBase={ghApiBase} navigateTo={navigateTo} />}
34+
searchSlot={archived ? undefined : <HeaderAnalyzeSelector apiBase={ghApiBase} navigateTo={navigateTo} />}
3135
>
32-
<RealtimeSummary apiBase={webApiBase} />
36+
{archived ? null : <RealtimeSummary apiBase={webApiBase} />}
3337
</SiteHeader>
3438
);
3539
}

‎apps/docs/lib/route-audit.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {isIP} from 'node:net';
22
import {unstable_rethrow} from 'next/navigation';
33

4-
type DocsRoute = '/api/search' | '/blog/feed.xml' | '/llms-full.txt' | '/llms.mdx/api'
4+
type DocsRoute = '/api/search' | '/docs/search' | '/blog/feed.xml' | '/llms-full.txt' | '/llms.mdx/api'
55
| '/llms.mdx/api/[slug]' | '/llms.mdx/docs/[[...slug]]';
66

77
function clientAddress(headers: Headers) {

‎apps/web/components/app-shell.tsx‎

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,13 @@
22

33
import { useCallback, useEffect } from 'react';
44
import { usePathname, useRouter } from 'next/navigation';
5-
import { SiteHeader, HeaderAnalyzeSelector, SunsetBanner, type SiteHeaderConfig } from '@repo/site-shell';
5+
import { SiteHeader, HeaderAnalyzeSelector, SunsetBanner, createArchiveHeaderItems } from '@repo/site-shell';
66
import { cn } from '@/lib/utils';
77
import config from '@/site.config';
88
import { RealtimeSummary } from '@/components/RealtimeSummary';
99

1010
// Archive mode keeps only links that still lead somewhere: no search, no live counter.
11-
const ARCHIVE_HEADER_ITEMS: SiteHeaderConfig['items'] = [
12-
{ label: 'Dataset', href: '/data' },
13-
{ label: 'Blog', href: '/blog', forceReload: true },
14-
{ label: 'About', href: '/docs/about', forceReload: true },
15-
{ label: 'GitHub', href: 'https://github.com/pingcap/ossinsight', newTab: true },
16-
'spacer',
17-
];
11+
const ARCHIVE_HEADER_ITEMS = createArchiveHeaderItems('web');
1812

1913
export function AppShell({
2014
children,

‎packages/site-shell/src/site-links.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,17 @@ export function createAppHeaderConfig(app: SiteApp, env: EnvMap = process.env):
125125
],
126126
};
127127
}
128+
129+
/**
130+
* Header links after the shutdown (archive mode). Both apps use the same list, so the menu does not
131+
* change when a visitor moves between the archive pages and the blog or docs: only pages that still exist.
132+
*/
133+
export function createArchiveHeaderItems(app: SiteApp, env: EnvMap = process.env): SiteHeaderConfig['items'] {
134+
return [
135+
{ label: 'Dataset', href: getCrossAppHref(app, 'web', '/data', env), forceReload: app !== 'web' },
136+
{ label: 'Blog', href: getCrossAppHref(app, 'docs', '/blog', env), forceReload: app !== 'docs' },
137+
{ label: 'About', href: getCrossAppHref(app, 'docs', '/docs/about', env), forceReload: app !== 'docs' },
138+
{ label: 'GitHub', href: 'https://github.com/pingcap/ossinsight', newTab: true },
139+
'spacer',
140+
];
141+
}

0 commit comments

Comments
 (0)