Skip to content

Commit df9d34c

Browse files
Roger-luoclaude
andcommitted
docs(website): move the API version selector into the header (prominent, /api-only)
The version selector now renders in the top bar on /api/** pages instead of only in the sidebar (where it was easy to miss, and never seen until you were deep inside a versioned page). Reuses the existing VersionSwitcher (which self-hides off /api/**), restyled compact for the header; removed the duplicate sidebar mount. Verified: the version select renders on /api/<version>/** pages and is absent on the landing, guides, and the /api overview. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d310db4 commit df9d34c

3 files changed

Lines changed: 12 additions & 8 deletions

File tree

website/src/components/Sidebar.astro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* every other page shows the stock sidebar unchanged.
1010
*/
1111
import Default from '@astrojs/starlight/components/Sidebar.astro';
12-
import VersionSwitcher from './VersionSwitcher.astro';
1312
---
1413

15-
<VersionSwitcher />
14+
{/* The API version selector now lives in the site header (SiteHeader.astro);
15+
this override is a pass-through kept for future sidebar customization. */}
1616
<Default><slot /></Default>

website/src/components/SiteHeader.astro

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import { primaryNav, githubUrl } from '../lib/nav';
2020
import logoLight from '../assets/logo.svg';
2121
import logoDark from '../assets/logo-dark.svg';
22+
// API version selector — self-hides unless the current URL is /api/<version>/…,
23+
// so it only appears in the header on versioned API pages.
24+
import VersionSwitcher from './VersionSwitcher.astro';
2225
2326
interface Props {
2427
/** Render the (docs-only) search slot region. */
@@ -41,6 +44,8 @@ const { withSearch = false } = Astro.props;
4144
)
4245
}
4346

47+
<VersionSwitcher />
48+
4449
<nav class="site-nav" aria-label="Primary">
4550
{
4651
primaryNav.map((item) => (

website/src/components/VersionSwitcher.astro

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,13 +75,12 @@ const show = current !== null && manifest.versions.length > 0;
7575
</script>
7676

7777
<style>
78+
/* Compact, inline treatment for the site header (the switcher now lives in
79+
the top bar rather than the sidebar). */
7880
.version-switcher {
7981
display: flex;
8082
align-items: center;
81-
gap: 0.5rem;
82-
padding: 0.5rem 0 0.75rem;
83-
margin-bottom: 0.5rem;
84-
border-bottom: 1px solid var(--sl-color-hairline-light);
83+
gap: 0.4rem;
8584
}
8685
.version-switcher__label {
8786
font-size: var(--sl-text-xs);
@@ -91,9 +90,9 @@ const show = current !== null && manifest.versions.length > 0;
9190
color: var(--sl-color-gray-3);
9291
}
9392
.version-switcher__select {
94-
flex: 1 1 auto;
93+
flex: 0 0 auto;
9594
min-width: 0;
96-
padding: 0.3rem 0.5rem;
95+
padding: 0.25rem 0.5rem;
9796
font-size: var(--sl-text-sm);
9897
color: var(--sl-color-white);
9998
background-color: var(--sl-color-black);

0 commit comments

Comments
 (0)