diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index d6f8436f07cf..15ef57a9af92 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -2,6 +2,12 @@ ## Unreleased +- Fixed a bug in which if `themeConfig.algolia` is not defined, the custom searchbar won't appear. +If you've swizzled Algolia `SearchBar` component before, please update your source code otherwise CSS might break. See [#1909](https://github.com/facebook/docusaurus/pull/1909/files) for reference. +```js +- ++
+``` - Reduce memory usage consumption. - Slightly adjust search icon position to be more aligned on small width device. - Convert sitemap plugin to TypeScript. diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js index fd4f323679cb..77f9211c17f9 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js @@ -52,7 +52,7 @@ function Navbar() { const [theme, setTheme] = useTheme(); const {siteConfig = {}} = context; const {baseUrl, themeConfig = {}} = siteConfig; - const {algolia, navbar = {}} = themeConfig; + const {navbar = {}} = themeConfig; const {title, logo = {}, links = []} = navbar; const showSidebar = useCallback(() => { @@ -137,14 +137,10 @@ function Navbar() { unchecked: , }} /> - {algolia && ( -
- -
- )} +
{ ); return isEnabled ? ( - +
{ onBlur={toggleSearchIconClick} ref={searchBarRef} /> - +
) : null; }; diff --git a/website/docs/search.md b/website/docs/search.md index 3635d8c8b6ae..fd79d3544af7 100644 --- a/website/docs/search.md +++ b/website/docs/search.md @@ -47,3 +47,5 @@ yarn swizzle @docusaurus/theme-classic SearchBar ``` This will create a `src/themes/SearchBar` file in your project folder. Restart your dev server and edit the component, you will see that Docusaurus uses your own `SearchBar` component now. + +**Notes**: You can alternatively [swizzle from Algolia SearchBar](#customizing-the-algolia-search-bar) and create your own search component from there. diff --git a/website/docs/theme-classic.md b/website/docs/theme-classic.md new file mode 100644 index 000000000000..e80e97a7fe41 --- /dev/null +++ b/website/docs/theme-classic.md @@ -0,0 +1,51 @@ +--- +id: theme-classic +title: Classic Theme Configuration +--- + +_This section is a work in progress._ + +## Navbar + +### Navbar Title & Logo + +You can add a logo and title to the navbar via `themeConfig.navbar`. Logo can be placed in [static folder](static-assets.md). + +```js +// docusaurus.config.js +module.exports = { + themeConfig: { + navbar: { + title: 'Site Title', + logo: { + alt: 'Site Logo', + src: 'img/logo.svg', + }, + } +} +``` + +### Navbar Links + +You can add links to the navbar via `themeConfig.navbar.links`: + +```js +// docusaurus/config.js +module.exports = { + themeConfig: { + navbar: { + links: [ + { + to: 'docs/docusaurus.config.js', + label: 'docusaurus.config.js', + position: 'left', + }, + // ... other links + ], + } +} +``` + +Outbound links automatically get `target="_blank" rel="noopener noreferrer"`. + +## Footer \ No newline at end of file diff --git a/website/sidebars.js b/website/sidebars.js index cc54508511ef..53cc6c815981 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -34,7 +34,7 @@ module.exports = { { type: 'category', label: 'Themes', - items: ['using-themes', 'advanced-themes'], + items: ['using-themes', 'advanced-themes', 'theme-classic'], }, 'presets', ],