From a6f53aa9d2c2172fcc7bb017c8226614885f7972 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lorber?= Date: Thu, 17 Feb 2022 14:24:31 +0100 Subject: [PATCH] refactor(theme-classic): bias again search metadata toward Algolia DocSearch (#6707) --- .../src/theme/SearchMetadata/index.tsx | 18 ++++++++---- .../src/theme/SearchMetadata/index.tsx | 28 ------------------- website/docs/search.md | 4 +-- 3 files changed, 14 insertions(+), 36 deletions(-) delete mode 100644 packages/docusaurus-theme-search-algolia/src/theme/SearchMetadata/index.tsx diff --git a/packages/docusaurus-theme-classic/src/theme/SearchMetadata/index.tsx b/packages/docusaurus-theme-classic/src/theme/SearchMetadata/index.tsx index 00ab2092c5..f25d951b8c 100644 --- a/packages/docusaurus-theme-classic/src/theme/SearchMetadata/index.tsx +++ b/packages/docusaurus-theme-classic/src/theme/SearchMetadata/index.tsx @@ -10,19 +10,25 @@ import React from 'react'; import Head from '@docusaurus/Head'; import type {Props} from '@theme/SearchMetadata'; -// Note: we don't couple this to Algolia/DocSearch on purpose -// We may want to support other search engine plugins too -// Search plugins should swizzle/override this comp to add their behavior +// Note: we bias toward using Algolia metadata on purpose +// Not doing so leads to confusion in the community, +// as it requires to first crawl the site with the Algolia plugin enabled first +// - https://github.com/facebook/docusaurus/issues/6693 +// - https://github.com/facebook/docusaurus/issues/4555 export default function SearchMetadata({ locale, version, tag, }: Props): JSX.Element { + // Seems safe to consider here the locale is the language, as the existing + // docsearch:language filter is afaik a regular string-based filter + const language = locale; + return ( - {locale && } - {version && } - {tag && } + {language && } + {version && } + {tag && } ); } diff --git a/packages/docusaurus-theme-search-algolia/src/theme/SearchMetadata/index.tsx b/packages/docusaurus-theme-search-algolia/src/theme/SearchMetadata/index.tsx deleted file mode 100644 index 2ca2a7c275..0000000000 --- a/packages/docusaurus-theme-search-algolia/src/theme/SearchMetadata/index.tsx +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -import React from 'react'; - -import Head from '@docusaurus/Head'; -import type {Props} from '@theme/SearchMetadata'; - -// Override default/agnostic SearchMetadata to use Algolia-specific metadata -function SearchMetadata({locale, version, tag}: Props): JSX.Element { - // Seems safe to consider here the locale is the language, as the existing - // docsearch:language filter is afaik a regular string-based filter - const language = locale; - - return ( - - {language && } - {version && } - {tag && } - - ); -} - -export default SearchMetadata; diff --git a/website/docs/search.md b/website/docs/search.md index 21dfa57dfa..d3b27ec96c 100644 --- a/website/docs/search.md +++ b/website/docs/search.md @@ -127,9 +127,9 @@ Refer to its [official DocSearch documentation](https://docsearch.algolia.com/do :::caution -The search feature will not work reliably until Algolia crawls your site with the **search plugin enabled**. +The search feature will not work reliably until Algolia crawls your site. -If you are installing the Algolia plugin for the first time and want to ensure the search feature works before deploying it to production, you can ask the DocSearch team to trigger a crawl on a staging environment url or deploy preview. +If search doesn't work after any significant change, please use the Algolia dashboard to **trigger a new crawl**. :::