Skip to content

Commit 24e5563

Browse files
Add v1.x info banner on every v1 docs page
Docusaurus's built-in DocVersionBanner only renders when a version declares a `banner` in docusaurus.config.js. v2.0 already ships an "unreleased" warning banner, but v1.x carried no banner — readers had to consult the version switcher in the navbar to know which major version they were viewing. Swizzle DocVersionBanner so v1.x pages render an info callout that states they are on v1.x (current stable) and links to the v2.0 introduction for preview. v2.0 pages continue to render the original unreleased banner unchanged. Addresses the "v1/v2 visual distinction on every page" deliverable in Docs Phase 0 (issue #234). Verified via npm run build that the banner appears on v1 pages and not on v2 pages, and that no internal links are broken. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent e57da73 commit 24e5563

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import React from 'react';
2+
import DocVersionBanner from '@theme-original/DocVersionBanner';
3+
import Link from '@docusaurus/Link';
4+
import {useDocsVersion} from '@docusaurus/theme-common/internal';
5+
6+
// Docusaurus only renders the built-in banner when a version declares
7+
// `banner` in docusaurus.config.js. v2.0 already shows an "unreleased"
8+
// warning banner; v1.x carries no banner by default. Until v2.0 ships,
9+
// this wrapper renders an info banner on v1.x pages so every page gives
10+
// readers a visual cue about which major version they are viewing —
11+
// not only the version switcher in the navbar.
12+
export default function DocVersionBannerWrapper(props) {
13+
const versionMetadata = useDocsVersion();
14+
15+
if (versionMetadata.version === '1.x') {
16+
return (
17+
<div
18+
className="alert alert--info margin-bottom--md"
19+
role="alert">
20+
<div>
21+
You are viewing the <b>v1.x</b> documentation (the current stable
22+
release line).
23+
</div>
24+
<div className="margin-top--md">
25+
v2.0 is in active development —{' '}
26+
<Link to="/docs/2.0/introduction">preview the v2.0 documentation</Link>.
27+
</div>
28+
</div>
29+
);
30+
}
31+
32+
return <DocVersionBanner {...props} />;
33+
}

0 commit comments

Comments
 (0)