Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dev/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ export default defineConfig({
},
{
version: "v1",
versionLabel: "v1 (legacy)",
title: "SolidBase v1 Demo",
themeConfig: {
sidebar: {
Expand Down
4 changes: 3 additions & 1 deletion docs/src/routes/guide/(2)config.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ interface SolidBaseConfig<ThemeConfig> {
robots?: boolean | RobotsConfig;
lang?: string;
locales?: Record<string, LocaleConfig<ThemeConfig>>;
versionLabel?: string;
routes?: SolidBaseRoutesConfig;
overrides?: Array<SolidBaseRouteOverride<ThemeConfig>>;
themeConfig?: ThemeConfig;
Expand Down Expand Up @@ -170,12 +171,13 @@ overrides: [
{
project: "solidbase",
version: "v1",
versionLabel: "v1 (legacy)",
},
],
// ..
```

Route override selectors use route axis names. Override config is applied over the base config, and `themeConfig` is shallow-merged with the base `themeConfig`.
Route override selectors use route axis names. Override config is applied over the base config, and `themeConfig` is shallow-merged with the base `themeConfig`. Use `versionLabel` to replace the active version selector label for a matching route without changing the version label shown elsewhere.

#### Miscellaneous options

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Version switcher for sites that configure `routes.version`.

- omitted when fewer than two version options are available
- uses Kobalte `Popover`
- uses the resolved `versionLabel` for the active version when configured
- displays each version option's `meta.label` when provided, otherwise the option name
- navigates to the selected version's route root
- scopes available versions to the current project
Expand Down
2 changes: 2 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const SOLID_BASE_OVERRIDE_CONFIG_KEYS = [
"issueAutolink",
"lang",
"locales",
"versionLabel",
"themeConfig",
"editPath",
"lastUpdated",
Expand All @@ -46,6 +47,7 @@ export interface SolidBaseConfig<ThemeConfig> {
issueAutolink?: IssueAutoLinkConfig | false;
lang?: string;
locales?: Record<string, LocaleConfig<ThemeConfig>>;
versionLabel?: string;
routes?: SolidBaseRoutesConfig;
overrides?: Array<SolidBaseRouteOverride<ThemeConfig>>;
themeConfig?: ThemeConfig;
Expand Down
4 changes: 3 additions & 1 deletion src/default-theme/components/VersionSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export default function VersionSelector() {
aria-label="Change version"
disabled={options().length <= 1}
>
<span class={styles.label}>{getOptionLabel(current())}</span>
<span class={styles.label}>
{config().versionLabel ?? getOptionLabel(current())}
</span>

<Show when={options().length > 1}>
<IconExpandUpDownLine class={styles.icon} aria-hidden />
Expand Down
2 changes: 1 addition & 1 deletion tests/config/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ describe("createSolidBase", () => {
solidBase.plugin({
routes: validRoutes,
overrides: [
{ version: "v1", title: "v1" },
{ version: "v1", versionLabel: "v1 (legacy)", title: "v1" },
{ locale: ["en", "fr"], themeConfig: { nav: [] } },
],
}),
Expand Down
2 changes: 2 additions & 0 deletions tests/config/route-config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ describe("route config helpers", () => {
project: "solid",
version: "v1",
locale: "fr",
versionLabel: "v1 (legacy)",
title: "Solid v1 FR",
},
],
Expand All @@ -236,6 +237,7 @@ describe("route config helpers", () => {

expect(config).toMatchObject({
title: "Solid v1 FR",
versionLabel: "v1 (legacy)",
themeConfig: {
nav: ["solid"],
sidebar: { "/fr": [] },
Expand Down
Loading