From dd0cfb7296be3e2ddc72ad79f8b5f08392d92aa7 Mon Sep 17 00:00:00 2001 From: endiliey Date: Tue, 29 Oct 2019 13:22:03 +0700 Subject: [PATCH 1/6] fix(v2): custom searchbar should appear even if themeconfig.algolia is undefined --- CHANGELOG-2.x.md | 1 + .../src/theme/Navbar/index.js | 16 +++--- website/docs/theme-classic.md | 51 +++++++++++++++++++ website/sidebars.js | 2 +- 4 files changed, 60 insertions(+), 10 deletions(-) create mode 100644 website/docs/theme-classic.md diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index d6f8436f07cf..ddd712b04842 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -2,6 +2,7 @@ ## Unreleased +- Fixed a bug in which if `themeConfig.algolia` is not defined, the custom searchbar won't appear. - 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..af75c4a58f8a 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,12 @@ function Navbar() { unchecked: , }} /> - {algolia && ( -
- -
- )} +
+ +
Date: Tue, 29 Oct 2019 13:28:15 +0700 Subject: [PATCH 2/6] nits --- .../docusaurus-theme-classic/src/theme/Navbar/index.js | 10 ++++------ .../src/theme/SearchBar/index.js | 5 ++--- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js index af75c4a58f8a..77f9211c17f9 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js @@ -137,12 +137,10 @@ function Navbar() { unchecked: , }} /> -
- -
+
{ ); return isEnabled ? ( - +
{ onBlur={toggleSearchIconClick} ref={searchBarRef} /> - +
) : null; }; From 0615c9fa190a2f75407f12214b731cd3f8fa7dbe Mon Sep 17 00:00:00 2001 From: endiliey Date: Tue, 29 Oct 2019 13:37:02 +0700 Subject: [PATCH 3/6] Docs docs --- website/docs/search.md | 2 ++ 1 file changed, 2 insertions(+) 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. From ab5d1b294fcac0dbd3c58271679d43d0e1c6fd58 Mon Sep 17 00:00:00 2001 From: endiliey Date: Tue, 29 Oct 2019 13:55:36 +0700 Subject: [PATCH 4/6] inaccuracy --- website/docs/theme-classic.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/theme-classic.md b/website/docs/theme-classic.md index 1f60324b9bf8..e80e97a7fe41 100644 --- a/website/docs/theme-classic.md +++ b/website/docs/theme-classic.md @@ -46,6 +46,6 @@ module.exports = { } ``` -Outbound links automatically get `target="_blank" rel="noopener noreferrer"`. You can offer `target` and `rel` to customize the attributes: +Outbound links automatically get `target="_blank" rel="noopener noreferrer"`. ## Footer \ No newline at end of file From 285aad7653fafd6dbabeb739249473b275c87957 Mon Sep 17 00:00:00 2001 From: endiliey Date: Tue, 29 Oct 2019 21:34:57 +0700 Subject: [PATCH 5/6] changelog --- CHANGELOG-2.x.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index ddd712b04842..eecc0f5165ff 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -3,6 +3,11 @@ ## 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 +```js +- ++
+``` - Reduce memory usage consumption. - Slightly adjust search icon position to be more aligned on small width device. - Convert sitemap plugin to TypeScript. From 72760b3cf841377f32ce4a142ba777112489371c Mon Sep 17 00:00:00 2001 From: endiliey Date: Tue, 29 Oct 2019 21:39:32 +0700 Subject: [PATCH 6/6] nits --- CHANGELOG-2.x.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG-2.x.md b/CHANGELOG-2.x.md index eecc0f5165ff..15ef57a9af92 100644 --- a/CHANGELOG-2.x.md +++ b/CHANGELOG-2.x.md @@ -3,7 +3,7 @@ ## 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 +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 - +