-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@vuepress-seach / Searchable paths #1032
Conversation
Please, please, it's very important! |
This would be 💯 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution, but I think that it's best to implement this API as string | RegExp | Array<RegExp>
instead of only indexOf
check.
}) | ||
return searchable | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code here can be simplified as:
isSearchable (page) {
const searchPaths = SEARCH_PATHS
// all paths searchables
if (searchPaths.length === 0) { return true }
return searchPaths.filter(path => {
return page.path.indexOf(path) !== -1
}).length > 0
},
So I recommend to name this API as
module.exports = {
plugins: [
['@vuepress/search', {
test: /1\.0/
}]
]
}
module.exports = {
plugins: [
['@vuepress/search', {
test: [ /1\.0/, /2\.0/ ]
}]
]
}
module.exports = {
plugins: [
['@vuepress/search', {
test: (currentPage, pages) => { }
}]
]
} |
@ulivz Done! |
Summary
What kind of change does this PR introduce?
Does this PR introduce a breaking change?
The PR fulfills these requirements:
You have tested in the following browsers: (Providing a detailed version will be better.)
If adding a new feature, the PR's description includes:
Other information
searchPaths
array
Set the array of searchable paths. Default value (a empty array) will search on all paths. Considering you have this structure:
You can restrict the searching setting with
searchPaths
as['/1.0/']
. Otherwise, the default search will return duplications, once you can have similar content between folders/1.0/
and/2.0/
.