Merge pull request #209 from postyizhan/Algolia

替换搜索为 Algolia
This commit is contained in:
lilingfengdev 2024-08-09 17:48:38 +08:00 committed by GitHub
commit a6c1a36a5c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 35 additions and 1 deletions

View File

@ -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: [

2
package-lock.json generated
View File

@ -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",

View File

@ -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",