Skip to content

Commit

Permalink
feat: add docusaurus versions dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
banasa44 committed Apr 29, 2024
1 parent 8248458 commit 066dca2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
16 changes: 7 additions & 9 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,10 @@ const config = {
sidebarPath: require.resolve('./sidebars.js'),
remarkPlugins: [math],
rehypePlugins: [katex],
includeCurrentVersion: false,
// lastVersion: 'current',
// onlyIncludeVersions: ['1.3.0'],
includeCurrentVersion: true,
versions: {
current: {
label: '1.4.0',
label: '1.4.0-alpha',
path: '1.4.0',
},
},
Expand Down Expand Up @@ -71,11 +69,11 @@ const config = {
src: 'img/logo-light.png',
},
items: [
// {
// type: 'docsVersionDropdown',
// position: 'right',
// dropdownActiveClassDisabled: true,
// },
{
type: 'docsVersionDropdown',
position: 'right',
dropdownActiveClassDisabled: true,
},
],
},
metadata: [
Expand Down
20 changes: 20 additions & 0 deletions src/theme/NavbarItem/DocsVersionDropdownNavbarItem.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import DocsVersionDropdownNavbarItem from '@theme-original/NavbarItem/DocsVersionDropdownNavbarItem';
import {useLocation} from '@docusaurus/router';

// We don't want to show the Versions Dropdown in the mainpage.
export default function DocsVersionDropdownNavbarItemWrapper(props) {
const {pathname} = useLocation();

const isRootPath = pathname === '' || pathname === '/';

// Render null if the pathname does not start with /docs
if (isRootPath) {
return null;
}
return (
<>
<DocsVersionDropdownNavbarItem {...props} />
</>
);
}

0 comments on commit 066dca2

Please sign in to comment.