内容搜索
约 264 字小于 1 分钟
2024-03-06
本地搜索
概述
为站点添加本地搜索。
关联插件: @vuepress-plume/plugin-search
该插件使用 minisearch 进行内容搜索。
默认配置:
.vuepress/config.ts
import { defineUserConfig } from 'vuepress'
import { plumeTheme } from 'vuepress-theme-plume'
export default defineUserConfig({
theme: plumeTheme({
search: {
provider: 'local',
// more options...
},
// 也可以通过 plugins.search 配置,但不推荐
plugins: {
search: {},
}
})
})配置
interface SearchOptions {
/**
* 本地搜索 国际化
*/
locales?: {
[locale: string]: SearchBoxLocale
}
/**
* 文章是否可被搜索,默认为 `() => true`
*/
isSearchable?: (page: Page) => boolean
}
interface SearchBoxLocale {
placeholder: string
buttonText: string
resetButtonTitle: string
backButtonTitle: string
noResultsText: string
footer: {
selectText: string
selectKeyAriaLabel: string
navigateText: string
navigateUpKeyAriaLabel: string
navigateDownKeyAriaLabel: string
closeText: string
closeKeyAriaLabel: string
}
}Algolia DocSearch
概述
使用 Algolia DocSearch 提供支持的网站内容搜索插件
关联插件:@vuepress/plugin-docsearch
查看 Algolia DocSearch 参考 获取更多信息。
启用
.vuepress/config.ts
import { defineUserConfig } from 'vuepress'
import { plumeTheme } from 'vuepress-theme-plume'
export default defineUserConfig({
theme: plumeTheme({
search: {
provider: 'algolia',
appId: 'YOUR_APP_ID',Object literal may only specify known properties, and 'appId' does not exist in type 'DocSearchOptions'. apiKey: 'YOUR_API_KEY',
indexName: 'YOUR_INDEX_NAME',
// more options
},
// 也可以通过 plugins.docsearch 配置,但不推荐
plugins: {
docsearch: {},
}
})
})贡献者
更新日志
2026/4/2 08:38
查看所有更新日志
aede6-fix(theme): twoslash comment error (#881)于4d236-feat(theme)!: add collections support (#704)于74dfa-docs: enable twoslash for code block于0fd6c-refactor(theme): improve types and flat config (#524)于0c53b-docs: improve docs (#332)于b079a-docs: update docs于2fb3d-docs: update theme docs于ca097-docs: lint fix于c56ba-feat: 全新的文档!于
