diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js index 30b1f67a4f50..16328e117876 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js @@ -26,7 +26,6 @@ function NavLink({activeBasePath, to, href, label, position, ...props}) { return ( ; + } + + return ( +
+ + {props.label} + + +
+ ); +} + +function MobileNavItem({items, ...props}) { + if (!items) { + return ( +
  • + +
  • + ); + } + + return ( +
  • + + {props.label} + + +
  • + ); +} + function Navbar() { const { siteConfig: { @@ -133,16 +184,16 @@ function Navbar() { )} {links - .filter(linkItem => linkItem.position !== 'right') + .filter(linkItem => linkItem.position === 'left') .map((linkItem, i) => ( - + ))}
    {links .filter(linkItem => linkItem.position === 'right') .map((linkItem, i) => ( - + ))} {!disableDarkMode && (
      {links.map((linkItem, i) => ( -
    • - -
    • + ))}
    diff --git a/website/docs/theme-classic.md b/website/docs/theme-classic.md index 83e975af6f05..8a381554617f 100644 --- a/website/docs/theme-classic.md +++ b/website/docs/theme-classic.md @@ -98,9 +98,9 @@ module.exports = { navbar: { links: [ { - to: 'docs/docusaurus.config.js', - label: 'docusaurus.config.js', - position: 'left', + to: 'docs/introduction', + label: 'Introduction', + position: 'left', // or 'right' // To apply the active class styling on all // routes starting with this path. activeBasePath: 'docs', @@ -115,6 +115,38 @@ module.exports = { Outbound links automatically get `target="_blank" rel="noopener noreferrer"` attributes. +### Navbar Dropdown + +Navbar items can also be dropdown items by specifying the `items`, an inner array of navbar links. + +```js {9-19} title="docusaurus.config.js" +module.exports = { + ... + themeConfig: { + navbar: { + links: [ + { + label: 'Community', + position: 'left', // or 'right' + items: [ + { + label: 'Facebook', + href: '...', + }, + { + label: 'GitHub', + href: '...', + }, + // ... more items + ], + }, + ], + }, + ... + }, +} +``` + ### Auto-hide sticky navbar You can enable this cool UI feature that automatically hides the navbar when a user starts scrolling down the page, and show it again when the user scrolls up. diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index 6cdb90b4cd0a..3cae3bf933a9 100644 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -91,25 +91,29 @@ module.exports = { }, links: [ { - to: 'versions', - label: `${versions[0].substr(6)}`, - position: 'left', - style: { - whiteSpace: 'nowrap', - padding: '0.25rem 0.5rem 0.2rem 0.25rem', - fontSize: 'calc(0.9 * var(--ifm-font-size-base))', - textDecoration: 'underline', - }, - }, - { - to: 'docs/introduction', - activeBasePath: 'docs', label: 'Docs', position: 'left', + activeBasePath: 'docs', + items: [ + { + label: versions[0], + to: `docs/introduction`, + }, + ].concat( + versions.slice(1).map(version => ({ + label: version, + to: `docs/${version}/introduction`, + })), + ), }, {to: 'blog', label: 'Blog', position: 'left'}, {to: 'showcase', label: 'Showcase', position: 'left'}, {to: 'feedback', label: 'Feedback', position: 'left'}, + { + to: 'versions', + label: `v${versions[0]}`, + position: 'right', + }, { href: 'https://github.com/facebook/docusaurus', label: 'GitHub', diff --git a/website/src/css/custom.css b/website/src/css/custom.css index 0d8cd4af0b05..5e6ea0d649b1 100644 --- a/website/src/css/custom.css +++ b/website/src/css/custom.css @@ -20,18 +20,6 @@ html[data-theme='dark'] { --ifm-color-feedback-background: #f0f8ff; } -@media screen and (max-width: 996px) { - :root { - --ifm-font-size-base: 15px; - } -} - -@media screen and (min-width: 997px) { - :root { - --ifm-font-size-base: 17px; - } -} - .docusaurus-highlight-code-line { background-color: rgb(0, 0, 0, 0.1); display: block; diff --git a/website/src/pages/index.js b/website/src/pages/index.js index 73c05dbd4629..7d367aa678e0 100644 --- a/website/src/pages/index.js +++ b/website/src/pages/index.js @@ -141,7 +141,6 @@ function Home() {

    Built Using React

    - quotes

    Extend or customize your project's layout by reusing React. Docusaurus can be extended while reusing the same header and