From fdf10541d8b38982e2096978114e28e5360e32a7 Mon Sep 17 00:00:00 2001 From: Endi Date: Wed, 8 May 2019 15:18:06 +0700 Subject: [PATCH] patch PR #1440 (#1441) * alternative implementation * typo * refactor noop * rename SearchAlgolia -> SearchBar * changes.md --- packages/docusaurus-preset-classic/src/index.js | 4 ++-- packages/docusaurus-theme-classic/src/index.js | 10 ---------- .../docusaurus-theme-classic/src/theme/Navbar/index.js | 4 ++-- .../docusaurus-theme-classic/src/theme/SearchBar.js | 8 ++++++++ .../src/theme/{SearchAlgolia => SearchBar}/index.js | 1 - .../src/theme/{SearchAlgolia => SearchBar}/styles.css | 0 packages/docusaurus/CHANGES.md | 4 ---- .../lib/client/exports/Noop.js} | 0 8 files changed, 12 insertions(+), 19 deletions(-) create mode 100644 packages/docusaurus-theme-classic/src/theme/SearchBar.js rename packages/docusaurus-theme-search-algolia/src/theme/{SearchAlgolia => SearchBar}/index.js (98%) rename packages/docusaurus-theme-search-algolia/src/theme/{SearchAlgolia => SearchBar}/styles.css (100%) rename packages/{docusaurus-theme-classic/src/noopModule.js => docusaurus/lib/client/exports/Noop.js} (100%) diff --git a/packages/docusaurus-preset-classic/src/index.js b/packages/docusaurus-preset-classic/src/index.js index a050e84ab770..a3f7ef8f56e3 100644 --- a/packages/docusaurus-preset-classic/src/index.js +++ b/packages/docusaurus-preset-classic/src/index.js @@ -9,10 +9,10 @@ module.exports = function preset(context, opts = {}) { return { themes: [ { - name: '@docusaurus/theme-search-algolia', + name: '@docusaurus/theme-classic', }, { - name: '@docusaurus/theme-classic', + name: '@docusaurus/theme-search-algolia', }, ], plugins: [ diff --git a/packages/docusaurus-theme-classic/src/index.js b/packages/docusaurus-theme-classic/src/index.js index 4d2a505c7b60..f47388e6c2ee 100644 --- a/packages/docusaurus-theme-classic/src/index.js +++ b/packages/docusaurus-theme-classic/src/index.js @@ -22,16 +22,6 @@ class DocusaurusThemeClassic { getThemePath() { return path.resolve(__dirname, './theme'); } - - configureWebpack() { - return { - resolve: { - alias: { - '@theme/SearchAlgolia': path.resolve(__dirname, './noopModule.js'), - }, - }, - }; - } } module.exports = DocusaurusThemeClassic; diff --git a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js index 2d34a78a59d4..82cc870ae0cc 100644 --- a/packages/docusaurus-theme-classic/src/theme/Navbar/index.js +++ b/packages/docusaurus-theme-classic/src/theme/Navbar/index.js @@ -10,7 +10,7 @@ import React from 'react'; import Link from '@docusaurus/Link'; import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; -import SearchAlgolia from '@theme/SearchAlgolia'; +import SearchBar from '@theme/SearchBar'; function Navbar() { const context = useDocusaurusContext(); @@ -75,7 +75,7 @@ function Navbar() {
{algolia && (
- +
)}
diff --git a/packages/docusaurus-theme-classic/src/theme/SearchBar.js b/packages/docusaurus-theme-classic/src/theme/SearchBar.js new file mode 100644 index 000000000000..b2c2e8a7e2b1 --- /dev/null +++ b/packages/docusaurus-theme-classic/src/theme/SearchBar.js @@ -0,0 +1,8 @@ +/** + * Copyright (c) 2017-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +export {default} from '@docusaurus/Noop'; diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchAlgolia/index.js b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js similarity index 98% rename from packages/docusaurus-theme-search-algolia/src/theme/SearchAlgolia/index.js rename to packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js index cb2706b7f93f..903dd696e8de 100644 --- a/packages/docusaurus-theme-search-algolia/src/theme/SearchAlgolia/index.js +++ b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/index.js @@ -21,7 +21,6 @@ class Search extends React.Component { componentDidMount() { const {siteConfig = {}, metadata = {}} = this.context; - console.log(siteConfig); const {version: thisVersion, language: thisLanguage} = metadata; const { themeConfig: {algolia}, diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchAlgolia/styles.css b/packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.css similarity index 100% rename from packages/docusaurus-theme-search-algolia/src/theme/SearchAlgolia/styles.css rename to packages/docusaurus-theme-search-algolia/src/theme/SearchBar/styles.css diff --git a/packages/docusaurus/CHANGES.md b/packages/docusaurus/CHANGES.md index 00c4d45bcc5a..4fb5fc1714fa 100644 --- a/packages/docusaurus/CHANGES.md +++ b/packages/docusaurus/CHANGES.md @@ -15,10 +15,6 @@ headerLinks: [ { url: "help", label: "Help" }, // Links to href destination/ external page { href: "https://github.com/", label: "GitHub" }, - // Determines search bar position among links - { search: true }, - // Determines language drop down position among links - { languages: true } ], ``` diff --git a/packages/docusaurus-theme-classic/src/noopModule.js b/packages/docusaurus/lib/client/exports/Noop.js similarity index 100% rename from packages/docusaurus-theme-classic/src/noopModule.js rename to packages/docusaurus/lib/client/exports/Noop.js