You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: website/docs/api/themes/theme-configuration.mdx
+12
Original file line number
Diff line number
Diff line change
@@ -597,11 +597,23 @@ Accepted fields:
597
597
|`dropdownItemsAfter`| <code>[LinkLikeItem](#navbar-dropdown)[]</code> |`[]`| Add additional dropdown items at the end of the dropdown. |
598
598
|`docsPluginId`|`string`|`'default'`| The ID of the docs plugin that the doc versioning belongs to. |
599
599
|`dropdownActiveClassDisabled`|`boolean`|`false`| Do not add the link active class when browsing docs. |
600
+
|`versions`|`DropdownVersions`|`undefined`| Specify a custom list of versions to include in the dropdown. See [the versioning guide](../../guides/docs/versioning.mdx#docsVersionDropdown) for details. |
600
601
601
602
```mdx-code-block
602
603
</APITable>
603
604
```
604
605
606
+
Types:
607
+
608
+
```ts
609
+
typeDropdownVersion= {
610
+
/** Allows you to provide a custom display label for each version. */
Copy file name to clipboardexpand all lines: website/docs/guides/docs/versioning.mdx
+47-1
Original file line number
Diff line number
Diff line change
@@ -258,7 +258,7 @@ See [docs plugin configuration](../../api/plugins/plugin-content-docs.mdx#config
258
258
259
259
## Navbar items {#navbar-items}
260
260
261
-
We offer several navbar items to help you quickly set up navigation without worrying about versioned routes.
261
+
We offer several docs navbar items to help you quickly set up navigation without worrying about versioned routes.
262
262
263
263
-[`doc`](../../api/themes/theme-configuration.mdx#navbar-doc-link): a link to a doc.
264
264
-[`docSidebar`](../../api/themes/theme-configuration.mdx#navbar-doc-sidebar): a link to the first item in a sidebar.
@@ -271,6 +271,52 @@ These links would all look for an appropriate version to link to, in the followi
271
271
2.**Preferred version**: the version that the user last viewed. If there's no history, fall back to...
272
272
3.**Latest version**: the default version that we navigate to, configured by the `lastVersion` option.
273
273
274
+
## `docsVersionDropdown`{#docsVersionDropdown}
275
+
276
+
By default, the [`docsVersionDropdown`](../../api/themes/theme-configuration.mdx#navbar-docs-version-dropdown) displays a dropdown with all the available docs versions.
277
+
278
+
The `versions` attribute allows you to display a subset of the available docs versions in a given order:
279
+
280
+
```js title="docusaurus.config.js"
281
+
exportdefault {
282
+
themeConfig: {
283
+
navbar: {
284
+
items: [
285
+
{
286
+
type:'docsVersionDropdown',
287
+
// highlight-start
288
+
versions: ['current', '3.0', '2.0'],
289
+
// highlight-end
290
+
},
291
+
],
292
+
},
293
+
},
294
+
};
295
+
```
296
+
297
+
Passing a `versions` object, lets you override the display label of each version:
298
+
299
+
```js title="docusaurus.config.js"
300
+
exportdefault {
301
+
themeConfig: {
302
+
navbar: {
303
+
items: [
304
+
{
305
+
type:'docsVersionDropdown',
306
+
// highlight-start
307
+
versions: {
308
+
current: {label:'Version 4.0'},
309
+
'3.0': {label:'Version 3.0'},
310
+
'2.0': {label:'Version 2.0'},
311
+
},
312
+
// highlight-end
313
+
},
314
+
],
315
+
},
316
+
},
317
+
};
318
+
```
319
+
274
320
## Recommended practices {#recommended-practices}
275
321
276
322
### Version your documentation only when needed {#version-your-documentation-only-when-needed}
0 commit comments