Skip to content

Commit

Permalink
feat(plugin-docsearch): add built-in locale (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mister-Hope authored Dec 29, 2024
1 parent bdb9902 commit cc734fb
Show file tree
Hide file tree
Showing 5 changed files with 830 additions and 2 deletions.
13 changes: 12 additions & 1 deletion plugins/search/plugin-docsearch/src/node/docsearchPlugin.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { getFullLocaleConfig } from '@vuepress/helper'
import type { Plugin } from 'vuepress/core'
import type { DocSearchOptions } from '../shared/index.js'
import { docSearchLocaleInfo } from './locales.js'
import { prepareClientConfig } from './prepareClientConfig.js'
import { PLUGIN_NAME } from './utils.js'

Expand All @@ -21,13 +23,22 @@ export interface DocSearchPluginOptions extends DocSearchOptions {
export const docsearchPlugin = ({
injectStyles = true,
indexBase,
locales = {},
...options
}: DocSearchPluginOptions = {}): Plugin => ({
name: PLUGIN_NAME,

define: (app) => ({
__DOCSEARCH_INDEX_BASE__: indexBase || app.siteData.base,
__DOCSEARCH_OPTIONS__: options,
__DOCSEARCH_OPTIONS__: {
...options,
locales: getFullLocaleConfig({
app,
default: docSearchLocaleInfo,
name: PLUGIN_NAME,
config: locales,
}),
},
}),

clientConfigFile: (app) => prepareClientConfig(app, injectStyles),
Expand Down
Loading

0 comments on commit cc734fb

Please sign in to comment.