Skip to content

Commit a6f53aa

Browse files
authored
refactor(theme-classic): bias again search metadata toward Algolia DocSearch (#6707)
1 parent 12aae9a commit a6f53aa

File tree

3 files changed

+14
-36
lines changed
  • packages
    • docusaurus-theme-classic/src/theme/SearchMetadata
    • docusaurus-theme-search-algolia/src/theme/SearchMetadata
  • website/docs

3 files changed

+14
-36
lines changed

packages/docusaurus-theme-classic/src/theme/SearchMetadata/index.tsx

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,25 @@ import React from 'react';
1010
import Head from '@docusaurus/Head';
1111
import type {Props} from '@theme/SearchMetadata';
1212

13-
// Note: we don't couple this to Algolia/DocSearch on purpose
14-
// We may want to support other search engine plugins too
15-
// Search plugins should swizzle/override this comp to add their behavior
13+
// Note: we bias toward using Algolia metadata on purpose
14+
// Not doing so leads to confusion in the community,
15+
// as it requires to first crawl the site with the Algolia plugin enabled first
16+
// - https://github.com/facebook/docusaurus/issues/6693
17+
// - https://github.com/facebook/docusaurus/issues/4555
1618
export default function SearchMetadata({
1719
locale,
1820
version,
1921
tag,
2022
}: Props): JSX.Element {
23+
// Seems safe to consider here the locale is the language, as the existing
24+
// docsearch:language filter is afaik a regular string-based filter
25+
const language = locale;
26+
2127
return (
2228
<Head>
23-
{locale && <meta name="docusaurus_locale" content={locale} />}
24-
{version && <meta name="docusaurus_version" content={version} />}
25-
{tag && <meta name="docusaurus_tag" content={tag} />}
29+
{language && <meta name="docsearch:language" content={language} />}
30+
{version && <meta name="docsearch:version" content={version} />}
31+
{tag && <meta name="docsearch:docusaurus_tag" content={tag} />}
2632
</Head>
2733
);
2834
}

packages/docusaurus-theme-search-algolia/src/theme/SearchMetadata/index.tsx

Lines changed: 0 additions & 28 deletions
This file was deleted.

website/docs/search.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ Refer to its [official DocSearch documentation](https://docsearch.algolia.com/do
127127

128128
:::caution
129129

130-
The search feature will not work reliably until Algolia crawls your site with the **search plugin enabled**.
130+
The search feature will not work reliably until Algolia crawls your site.
131131

132-
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.
132+
If search doesn't work after any significant change, please use the Algolia dashboard to **trigger a new crawl**.
133133

134134
:::
135135

0 commit comments

Comments
 (0)