Skip to content

Commit f8fac38

Browse files
authored
docs(rspress): use @rspress/plugin-algolia for search (#1015)
1 parent e3c9b45 commit f8fac38

File tree

4 files changed

+278
-1
lines changed

4 files changed

+278
-1
lines changed

pnpm-lock.yaml

Lines changed: 252 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/core": "1.3.21",
1313
"@rsbuild/plugin-sass": "^1.3.1",
1414
"@rslib/tsconfig": "workspace:*",
15+
"@rspress/plugin-algolia": "2.0.0-beta.6",
1516
"@rspress/plugin-llms": "2.0.0-beta.6",
1617
"@rspress/plugin-rss": "2.0.0-beta.6",
1718
"@rstack-dev/doc-ui": "1.10.2",

website/rspress.config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import path from 'node:path';
22
import { pluginSass } from '@rsbuild/plugin-sass';
3+
import { pluginAlgolia } from '@rspress/plugin-algolia';
34
import { pluginLlms } from '@rspress/plugin-llms';
45
import { pluginRss } from '@rspress/plugin-rss';
56
import {
@@ -16,6 +17,7 @@ const description = 'The Rsbuild-based library development tool';
1617

1718
export default defineConfig({
1819
plugins: [
20+
pluginAlgolia(),
1921
pluginFontOpenSans(),
2022
pluginLlms(),
2123
pluginRss({

website/theme/index.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,34 @@
1+
import {
2+
Search as PluginAlgoliaSearch,
3+
ZH_LOCALES,
4+
} from '@rspress/plugin-algolia/runtime';
15
import { NavIcon } from '@rstack-dev/doc-ui/nav-icon';
26
import { Layout as BaseLayout } from 'rspress/theme';
37
import { HomeLayout } from './pages';
48
import './index.scss';
9+
import { useLang } from 'rspress/runtime';
510

611
const Layout = () => {
712
return <BaseLayout beforeNavTitle={<NavIcon />} />;
813
};
914

10-
export { Layout, HomeLayout };
15+
const Search = () => {
16+
const lang = useLang();
17+
return (
18+
<PluginAlgoliaSearch
19+
docSearchProps={{
20+
appId: 'TICGXW7OMD', // cspell:disable-line
21+
apiKey: '08656eae2f8e85d7f3473574000889f2', // cspell:disable-line
22+
indexName: 'lib',
23+
searchParameters: {
24+
facetFilters: [`lang:${lang}`],
25+
},
26+
}}
27+
locales={ZH_LOCALES}
28+
/>
29+
);
30+
};
31+
32+
export { Layout, HomeLayout, Search };
1133

1234
export * from 'rspress/theme';

0 commit comments

Comments
 (0)