From 70b1f27307c0080e76ff88a00321e6d10aa0a84e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cpostyizhan=E2=80=9D?= <“185839426@qq.com”> Date: Wed, 7 Aug 2024 19:01:28 +0800 Subject: [PATCH] algolia --- docusaurus.config.js | 33 ++++++++++++++++++++++++++++++++- package-lock.json | 2 ++ package.json | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/docusaurus.config.js b/docusaurus.config.js index b5535a080..7e22af866 100644 --- a/docusaurus.config.js +++ b/docusaurus.config.js @@ -8,7 +8,6 @@ import { themes as prismThemes } from "prism-react-renderer"; /** @type {import('@docusaurus/types').Config} */ const config = { - customFields: { // 标题前缀 titlePrefix: "主页", @@ -213,6 +212,38 @@ const config = { colorMode: { respectPrefersColorScheme: true, }, + + // 搜索 + algolia: { + // The application ID provided by Algolia + appId: 'D1KV1BYF3B', + + // Public API key: it is safe to commit it + apiKey: '4bb3573e59f2c49f30f057ce54edab3f', + + indexName: 'yizhan', + + // Optional: see doc section below + contextualSearch: true, + + // Optional: Specify domains where the navigation should occur through window.location instead on history.push. Useful when our Algolia config crawls multiple documentation sites and we want to navigate with window.location.href to them. + externalUrlRegex: 'external\\.com|domain\\.com', + + // Optional: Replace parts of the item URLs from Algolia. Useful when using the same search index for multiple deployments using a different baseUrl. You can use regexp or string in the `from` param. For example: localhost:3000 vs myCompany.com/docs + replaceSearchResultPathname: { + from: '/docs/', // or as RegExp: /\/docs\// + to: '/', + }, + + // Optional: Algolia search parameters + searchParameters: {}, + + // Optional: path for search page that enabled by default (`false` to disable it) + searchPagePath: 'search', + + // Optional: whether the insights feature is enabled or not on Docsearch (`false` by default) + insights: false, + }, }), themes: [ diff --git a/package-lock.json b/package-lock.json index 7d82f7ae1..4a876e0ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@docusaurus/plugin-sitemap": "^3.4.0", "@docusaurus/preset-classic": "3.4.0", "@docusaurus/theme-mermaid": "^3.4.0", + "@docusaurus/theme-search-algolia": "^3.4.0", "@easyops-cn/docusaurus-search-local": "^0.44.3", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0", @@ -2617,6 +2618,7 @@ "version": "3.4.0", "resolved": "https://registry.npmjs.org/@docusaurus/theme-search-algolia/-/theme-search-algolia-3.4.0.tgz", "integrity": "sha512-aiHFx7OCw4Wck1z6IoShVdUWIjntC8FHCw9c5dR8r3q4Ynh+zkS8y2eFFunN/DL6RXPzpnvKCg3vhLQYJDmT9Q==", + "license": "MIT", "dependencies": { "@docsearch/react": "^3.5.2", "@docusaurus/core": "3.4.0", diff --git a/package.json b/package.json index 6a46fa3e7..8fc628ced 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "@docusaurus/plugin-sitemap": "^3.4.0", "@docusaurus/preset-classic": "3.4.0", "@docusaurus/theme-mermaid": "^3.4.0", + "@docusaurus/theme-search-algolia": "^3.4.0", "@easyops-cn/docusaurus-search-local": "^0.44.3", "@mdx-js/react": "^3.0.0", "clsx": "^2.0.0",