mirror of
https://github.com/facebook/docusaurus.git
synced 2025-12-26 01:33:02 +00:00
refactor(theme-classic): bias again search metadata toward Algolia DocSearch (#6707)
This commit is contained in:
parent
12aae9a086
commit
a6f53aa9d2
|
|
@ -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 (
|
||||
<Head>
|
||||
{locale && <meta name="docusaurus_locale" content={locale} />}
|
||||
{version && <meta name="docusaurus_version" content={version} />}
|
||||
{tag && <meta name="docusaurus_tag" content={tag} />}
|
||||
{language && <meta name="docsearch:language" content={language} />}
|
||||
{version && <meta name="docsearch:version" content={version} />}
|
||||
{tag && <meta name="docsearch:docusaurus_tag" content={tag} />}
|
||||
</Head>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 (
|
||||
<Head>
|
||||
{language && <meta name="docsearch:language" content={language} />}
|
||||
{version && <meta name="docsearch:version" content={version} />}
|
||||
{tag && <meta name="docsearch:docusaurus_tag" content={tag} />}
|
||||
</Head>
|
||||
);
|
||||
}
|
||||
|
||||
export default SearchMetadata;
|
||||
|
|
@ -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**.
|
||||
|
||||
:::
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue