Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/SearchBox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default {
/* global OPTIONS */
mounted() {
const options = OPTIONS || {}
flexsearchSvc.buildIndex(this.$site.pages, options)
flexsearchSvc.buildIndex(this.$site.pages, options, this.$localePath)
this.placeholder = this.$site.themeConfig.searchPlaceholder || ''
document.addEventListener('keydown', this.onHotkey)

Expand Down
5 changes: 3 additions & 2 deletions services/flexsearchSvc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ let pagesByPath = null
const cjkRegex = /[\u3131-\u314e|\u314f-\u3163|\uac00-\ud7a3]|[\u4E00-\u9FCC\u3400-\u4DB5\uFA0E\uFA0F\uFA11\uFA13\uFA14\uFA1F\uFA21\uFA23\uFA24\uFA27-\uFA29]|[\ud840-\ud868][\udc00-\udfff]|\ud869[\udc00-\uded6\udf00-\udfff]|[\ud86a-\ud86c][\udc00-\udfff]|\ud86d[\udc00-\udf34\udf40-\udfff]|\ud86e[\udc00-\udc1d]|[\u3041-\u3096]|[\u30A1-\u30FA]/giu

export default {
buildIndex(allPages, options) {
const pages = allPages.filter(p => !p.frontmatter || p.frontmatter.search !== false)
buildIndex(allPages, options, localePath) {
const pages = allPages.filter(p => !p.frontmatter || p.frontmatter.search !== false && (p.path.startsWith(localePath) || p.path === '/'))

const indexSettings = {
encode: options.encode || 'simple',
tokenize: options.tokenize || 'forward',
Expand Down