Skip to content

Commit b4e8782

Browse files
authored
docs: use Algolia search (#541)
1 parent 94c3159 commit b4e8782

File tree

4 files changed

+292
-1
lines changed

4 files changed

+292
-1
lines changed

pnpm-lock.yaml

Lines changed: 264 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

website/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@rsbuild/plugin-sass": "^1.4.0",
1313
"@rspress/core": "^2.0.0-beta.31",
1414
"@rspress/plugin-llms": "2.0.0-beta.31",
15+
"@rspress/plugin-algolia": "2.0.0-beta.31",
1516
"@rstack-dev/doc-ui": "1.11.0",
1617
"@rstest/tsconfig": "workspace:*",
1718
"@types/node": "^22.13.8",

website/rspress.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as path from 'node:path';
22
import { pluginSass } from '@rsbuild/plugin-sass';
33
import { defineConfig } from '@rspress/core';
4+
import { pluginAlgolia } from '@rspress/plugin-algolia';
45
import { pluginLlms } from '@rspress/plugin-llms';
56
import { pluginGoogleAnalytics } from 'rsbuild-plugin-google-analytics';
67
import { pluginOpenGraph } from 'rsbuild-plugin-open-graph';
@@ -73,6 +74,9 @@ export default defineConfig({
7374
],
7475
},
7576
plugins: [
77+
pluginAlgolia({
78+
verificationContent: '71ECBF977243215D',
79+
}),
7680
pluginFontOpenSans(),
7781
pluginSitemap({
7882
domain: siteUrl,

website/theme/index.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
import { useLang } from '@rspress/core/runtime';
12
import {
23
Layout as BaseLayout,
34
getCustomMDXComponent as basicGetCustomMDXComponent,
45
} from '@rspress/core/theme';
6+
import {
7+
Search as PluginAlgoliaSearch,
8+
ZH_LOCALES,
9+
} from '@rspress/plugin-algolia/runtime';
510
import {
611
LlmsContainer,
712
LlmsCopyButton,
@@ -32,10 +37,27 @@ export function getCustomMDXComponent() {
3237
};
3338
}
3439

40+
const Search = () => {
41+
const lang = useLang();
42+
return (
43+
<PluginAlgoliaSearch
44+
docSearchProps={{
45+
appId: 'TRUZL3HFAU', // cspell:disable-line
46+
apiKey: '3cf720e0589287b96f68a8c7bad7f682', // cspell:disable-line
47+
indexName: 'rstest',
48+
searchParameters: {
49+
facetFilters: [`lang:${lang}`],
50+
},
51+
}}
52+
locales={ZH_LOCALES}
53+
/>
54+
);
55+
};
56+
3557
const Layout = () => {
3658
return <BaseLayout beforeNavTitle={<NavIcon />} />;
3759
};
3860

39-
export { Layout, HomeLayout };
61+
export { Search, Layout, HomeLayout };
4062

4163
export * from '@rspress/core/theme';

0 commit comments

Comments
 (0)