Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
feat: add support for browser-based theme config file (docusaurus.theme.js)#9619
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:main
Are you sure you want to change the base?
Changes from1 commit
1659b954f70bf39bc8675e2413544924cd760a04cf7ee136cebcec4b38737e2fe7916b9e8768c67056e9161c727File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
- Loading branch information
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,14 +8,24 @@ import type {ReactNode} from 'react'; | ||
| import React from 'react'; | ||
| import Link from '@docusaurus/Link'; | ||
| import Translate from '@docusaurus/Translate'; | ||
| import VersionsArchived from './versionsArchived.json'; | ||
| import PrismLight from './src/utils/prismLight'; | ||
| import PrismDark from './src/utils/prismDark'; | ||
| import type * as Preset from '@docusaurus/preset-classic'; | ||
| // TODO remove this eslint ruse | ||
| // TODO PrismDark and PrismLight types | ||
| // TODO `satisfies Preset.ThemeConfig` `satisfies Config` | ||
| // results Expected ';', got 'satisfies' | ||
| /* eslint-disable @docusaurus/no-untranslated-text */ | ||
| const ArchivedVersionsDropdownItems = Object.entries(VersionsArchived).splice( | ||
| 0, | ||
| 5, | ||
| ); | ||
| const isDev = process.env.NODE_ENV === 'development'; | ||
| export default { | ||
| announcementBar: { | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others.Learn more. process is not defined for agolia however no error reported for navbar Debug label with isDev | ||
| id: 'announcementBar-3', // Increment on change | ||
| content: function AnnouncementBarContent(): ReactNode { | ||
| return ( | ||
| <b> | ||
| @@ -190,6 +200,110 @@ export default { | ||
| src: '/img/meta_opensource_logo_negative.svg', | ||
| href: 'https://opensource.fb.com', | ||
| }, | ||
| copyright: `Copyright © ${new Date().getFullYear()} Meta Platforms, Inc. Built with Docusaurus.`, | ||
| }, | ||
| navbar: { | ||
| hideOnScroll: true, | ||
| title: 'Docusaurus', | ||
| logo: { | ||
| alt: '', | ||
| src: 'img/docusaurus.svg', | ||
| srcDark: 'img/docusaurus_keytar.svg', | ||
| width: 32, | ||
| height: 32, | ||
| }, | ||
| items: [ | ||
| { | ||
| type: 'doc', | ||
| position: 'left', | ||
| docId: 'introduction', | ||
| label: 'Docs', | ||
| }, | ||
| { | ||
| type: 'docSidebar', | ||
| position: 'left', | ||
| sidebarId: 'api', | ||
| label: 'API', | ||
| }, | ||
| {to: 'blog', label: 'Blog', position: 'left'}, | ||
| {to: 'showcase', label: 'Showcase', position: 'left'}, | ||
| { | ||
| to: '/community/support', | ||
| label: 'Community', | ||
| position: 'left', | ||
| activeBaseRegex: `/community/`, | ||
| }, | ||
| // This item links to a draft doc: only displayed in dev | ||
| { | ||
| type: 'doc', | ||
| docId: 'index', | ||
| label: 'Tests', | ||
| docsPluginId: 'docs-tests', | ||
| }, | ||
| isDev && {to: '/__docusaurus/debug', label: 'Debug'}, | ||
| // Custom item for dogfooding: only displayed in /tests/ routes | ||
| { | ||
| type: 'custom-dogfood-navbar-item', | ||
| content: '😉', | ||
| }, | ||
| // Right | ||
| { | ||
| type: 'docsVersionDropdown', | ||
| position: 'right', | ||
| dropdownActiveClassDisabled: true, | ||
| dropdownItemsAfter: [ | ||
| { | ||
| type: 'html', | ||
| value: '<hr class="dropdown-separator">', | ||
| }, | ||
| { | ||
| type: 'html', | ||
| className: 'dropdown-archived-versions', | ||
| value: '<b>Archived versions</b>', | ||
| }, | ||
| ...ArchivedVersionsDropdownItems.map(([versionName, versionUrl]) => ({ | ||
| label: versionName, | ||
| href: versionUrl, | ||
| })), | ||
| { | ||
| href: 'https://v1.docusaurus.io', | ||
| label: '1.x.x', | ||
| }, | ||
| { | ||
| type: 'html', | ||
| value: '<hr class="dropdown-separator">', | ||
| }, | ||
| { | ||
| to: '/versions', | ||
| label: 'All versions', | ||
| }, | ||
| ], | ||
| dropdownItemsBefore: [], | ||
| }, | ||
| { | ||
| type: 'localeDropdown', | ||
| position: 'right', | ||
| dropdownItemsAfter: [ | ||
| { | ||
| type: 'html', | ||
| value: '<hr style="margin: 0.3rem 0;">', | ||
| }, | ||
| { | ||
| href: 'https://github.com/facebook/docusaurus/issues/3526', | ||
| label: 'Help Us Translate', | ||
| }, | ||
| ], | ||
| dropdownItemsBefore: [], | ||
| }, | ||
| { | ||
| href: 'https://github.com/facebook/docusaurus', | ||
| position: 'right', | ||
| className: 'header-github-link', | ||
| 'aria-label': 'GitHub repository', | ||
| }, | ||
| ] | ||
| // TODO fix type | ||
| .filter(Boolean) as NonNullable<Preset.ThemeConfig['navbar']>['items'], | ||
| }, | ||
| }; | ||
| // satisfies Preset.ThemeConfig; | ||