fuc-new/doc/node_modules/@vuepress/plugin-docsearch/lib/node/index.d.ts
hellcat 6adbc04d4b 1
2025-10-03 17:17:08 +08:00

88 lines
2.2 KiB
TypeScript

import { Plugin } from 'vuepress/core';
import { DocSearchProps } from '@docsearch/react';
import { LocaleConfig } from 'vuepress/shared';
import { DeepRequired } from '@vuepress/helper/shared';
type DocSearchLocaleData = DeepRequired<Pick<DocSearchProps, 'placeholder' | 'translations'>>;
/**
* DocSearch locale options
*
* DocSearch 多语言选项
*/
type DocSearchLocaleOptions = Partial<Pick<DocSearchProps, 'apiKey' | 'appId' | 'disableUserPersonalization' | 'indexName' | 'initialQuery' | 'maxResultsPerGroup' | 'placeholder' | 'searchParameters' | 'translations'>>;
/**
* DocSearch options
*
* DocSearch 选项
*/
interface DocSearchOptions extends DocSearchLocaleOptions {
/**
* Locale options
*
* 多语言选项
*/
locales?: LocaleConfig<DocSearchLocaleOptions>;
}
/**
* Options for @vuepress/plugin-docsearch
*
* @vuepress/plugin-docsearch 的配置项
*/
interface DocSearchPluginOptions extends DocSearchOptions {
/**
* Base path of the search index
*
* 搜索索引的基础路径
*
* @default app.siteData.base
*/
indexBase?: string;
/**
* Whether to inject docsearch default styles
*
* 是否注入 docsearch 的默认样式
*
* @default true
*/
injectStyles?: boolean;
}
/**
* DocSearch plugin
*
* DocSearch 插件
*
* @param options - DocSearch plugin options / DocSearch 插件选项
*
* @example
* ```ts
* import { docsearchPlugin } from '@vuepress/plugin-docsearch'
*
* export default {
* plugins: [
* docsearchPlugin({
* appId: 'XXXXXX',
* apiKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
* indexName: 'xxxxxxxx',
* locales: {
* '/': {
* placeholder: 'Search Documentation',
* },
* '/zh/': {
* placeholder: '搜索文档',
* },
* },
* }),
* ],
* }
* ```
*
* @returns Plugin object / 插件对象
*/
declare const docsearchPlugin: ({ injectStyles, indexBase, locales, ...options }?: DocSearchPluginOptions) => Plugin;
export { docsearchPlugin };
export type { DocSearchLocaleData, DocSearchLocaleOptions, DocSearchOptions, DocSearchPluginOptions };