File tree Expand file tree Collapse file tree 3 files changed +26
-7
lines changed
Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ " @alauda/doom " : patch
3+ ---
4+
5+ fix: add zh locale support for algolia search
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ export const ACP_BASE = '/container_platform/'
22
33export const FALSY_VALUES = new Set ( [
44 null ,
5+ undefined ,
56 '' ,
67 '0' ,
78 'false' ,
Original file line number Diff line number Diff line change 1+ import { useLang } from '@rspress/core/runtime'
12import { Search as OriginalSearch } from '@rspress/core/theme'
2- import { Search as AlgoliaSearch } from '@rspress/plugin-algolia/runtime'
3+ import {
4+ Search as AlgoliaSearch ,
5+ ZH_LOCALES ,
6+ } from '@rspress/plugin-algolia/runtime'
7+ import { useMemo } from 'react'
38
49const Search =
510 process . env . ALGOLIA_APP_ID &&
611 process . env . ALGOLIA_API_KEY &&
712 process . env . ALGOLIA_INDEX_NAME
8- ? ( ) => (
9- < AlgoliaSearch
10- docSearchProps = { {
13+ ? ( ) => {
14+ const lang = useLang ( )
15+ const docSearchProps = useMemo (
16+ ( ) => ( {
1117 appId : process . env . ALGOLIA_APP_ID ! ,
1218 apiKey : process . env . ALGOLIA_API_KEY ! ,
1319 indexName : process . env . ALGOLIA_INDEX_NAME ! ,
14- } }
15- />
16- )
20+ searchParameters : {
21+ facetFilters : [ `language:${ lang } ` ] ,
22+ } ,
23+ } ) ,
24+ [ lang ] ,
25+ )
26+ return (
27+ < AlgoliaSearch docSearchProps = { docSearchProps } locales = { ZH_LOCALES } />
28+ )
29+ }
1730 : OriginalSearch
1831
1932// eslint-disable-next-line import-x/export
You can’t perform that action at this time.
0 commit comments