mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-15 08:59:15 +08:00
0d619766e0
close #30812
29 lines
885 B
TypeScript
29 lines
885 B
TypeScript
import { DocSearchHit } from '@docsearch/react/dist/esm/types';
|
|
|
|
let _internalATag: HTMLAnchorElement | null;
|
|
|
|
export function transformHitUrl(hitUrl: string) {
|
|
_internalATag = _internalATag || document.createElement('a');
|
|
// `new URL` is not supported in IE
|
|
_internalATag.href = hitUrl;
|
|
return `${_internalATag.pathname}${window.location.search || ''}${_internalATag.hash}`;
|
|
}
|
|
|
|
export const AlgoliaConfig = {
|
|
appId: 'BH4D9OD16A',
|
|
apiKey: '60ac2c1a7d26ab713757e4a081e133d0',
|
|
indexName: 'ant_design',
|
|
getSearchParams(isZhCN: boolean) {
|
|
return { facetFilters: [`tags:${isZhCN ? 'cn' : 'en'}`] };
|
|
},
|
|
transformData(hits: DocSearchHit[]) {
|
|
hits.forEach(hit => {
|
|
hit.url = transformHitUrl(hit.url);
|
|
});
|
|
return hits;
|
|
},
|
|
debug: false, // Set debug to true if you want to inspect the dropdown
|
|
};
|
|
|
|
export type IAlgoliaConfig = typeof AlgoliaConfig;
|