diff --git a/docusaurus.config.js b/docusaurus.config.js
index 2a29308f75b94..bde58d780c79d 100644
--- a/docusaurus.config.js
+++ b/docusaurus.config.js
@@ -89,6 +89,13 @@ const SKIP_BLOG = LANDING_ONLY || process.env.SKIP_BLOG === 'true';
const SKIP_COMMUNITY = LANDING_ONLY || process.env.SKIP_COMMUNITY === 'true';
const SKIP_RELEASES = LANDING_ONLY || process.env.SKIP_RELEASES === 'true';
const SKIP_SEARCH = LANDING_ONLY || process.env.SKIP_SEARCH === 'true';
+// Opt-in Algolia DocSearch, gated by env so we can A/B against the existing
+// local search before cutting over. When true, the Algolia theme is loaded
+// ALONGSIDE the local-search theme (the local theme stays so its @generated
+// index module keeps compiling), and the SearchBar swizzle renders Algolia's
+// bar instead of the local one. Requires ALGOLIA_APP_ID / ALGOLIA_SEARCH_API_KEY
+// / ALGOLIA_INDEX_NAME to be set, or the Algolia theme validation will fail.
+const USE_ALGOLIA = !SKIP_SEARCH && process.env.USE_ALGOLIA === 'true';
const LINK_BEHAVIOR_VALUES = new Set(['ignore', 'log', 'warn', 'throw']);
function getBrokenLinkBehavior(envName, fallback) {
@@ -188,7 +195,10 @@ const config = {
},
],
projectName: 'apache/doris-website', // Usually your repo name.
- customFields: {},
+ customFields: {
+ // Read by the SearchBar swizzle to choose Algolia vs local search.
+ useAlgolia: USE_ALGOLIA,
+ },
future: {
experimental_faster: true,
},
@@ -386,10 +396,30 @@ const config = {
ignoreFiles: [/^docs\/(?:[^/]+\/)?key-features\//],
},
],
+ // Algolia DocSearch (modal-only; see `searchPagePath: false` below).
+ // Loaded additively so the local-search @generated module still exists
+ // for the SearchBar swizzle; which bar actually renders is decided at
+ // runtime via customFields.useAlgolia.
+ ...(USE_ALGOLIA ? ['@docusaurus/theme-search-algolia'] : []),
],
themeConfig:
/** @type {import('@docusaurus/preset-classic').ThemeConfig} */
({
+ // Present only when USE_ALGOLIA is set. The Algolia theme validates
+ // these, so appId / apiKey (search-only key) / indexName must come
+ // from the environment. searchPagePath:false keeps DocSearch as a
+ // modal so it doesn't fight the local-search /search route.
+ ...(USE_ALGOLIA
+ ? {
+ algolia: {
+ appId: process.env.ALGOLIA_APP_ID,
+ apiKey: process.env.ALGOLIA_SEARCH_API_KEY,
+ indexName: process.env.ALGOLIA_INDEX_NAME,
+ contextualSearch: true,
+ searchPagePath: false,
+ },
+ }
+ : {}),
matomo: {
matomoUrl: 'https://analytics.apache.org/',
siteId: '43',
diff --git a/package.json b/package.json
index 3a7437e93d015..d2f4387fad144 100644
--- a/package.json
+++ b/package.json
@@ -51,6 +51,7 @@
"@docusaurus/plugin-client-redirects": "3.6.3",
"@docusaurus/plugin-pwa": "3.6.3",
"@docusaurus/preset-classic": "3.6.3",
+ "@docusaurus/theme-search-algolia": "3.6.3",
"@emotion/css": "^11.13.5",
"@mdx-js/react": "^3.0.0",
"@yang1666204/docusaurus-search-local": "0.0.7",
diff --git a/src/theme/SearchBar/index.js b/src/theme/SearchBar/index.js
index 369df710bfdef..171ecee974329 100644
--- a/src/theme/SearchBar/index.js
+++ b/src/theme/SearchBar/index.js
@@ -1,3 +1,19 @@
+import React from "react";
+import useDocusaurusContext from "@docusaurus/useDocusaurusContext";
import "../../utils/proxiedGenerated";
-import SearchBar from "./SearchBar";
-export default SearchBar;
+import LocalSearchBar from "./SearchBar";
+import AlgoliaSearchBar from "@docusaurus/theme-search-algolia/lib/theme/SearchBar";
+
+// Env-gated swizzle: render Algolia's DocSearch bar when USE_ALGOLIA was set at
+// build time (surfaced via customFields.useAlgolia), otherwise the existing
+// local search bar. Both modules are imported unconditionally — they only run
+// their themeConfig-dependent hooks when actually mounted, so the unused branch
+// is inert.
+export default function SearchBar(props) {
+ const { siteConfig } = useDocusaurusContext();
+ return siteConfig.customFields?.useAlgolia ? (
+
+ ) : (
+
+ );
+}
diff --git a/static/robots.txt b/static/robots.txt
index e4a626ee00a9e..5b691dbad455a 100644
--- a/static/robots.txt
+++ b/static/robots.txt
@@ -1,3 +1,5 @@
+# Algolia-Crawler-Verif: AD8797796C86C8D5
+
User-agent: Googlebot
Allow: /