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
add support for hooks functions, setting query from URL, search exclusion #10
Conversation
Thanks! That feature looks sweet, let's make it official. I'd prefer to add more abstract hook Will be awesome if you'll find time to prepare it. |
@leo-buneev I'd be happy to - will update this PR and ping you with a nicer implementation 🚀 |
@leo-buneev unfortunately, 5279837 is the only practical way to implement this API within the Vuepress plugin framework - let me know what you think! You can see one use case at ubclaunchpad/UBC-LAUNCH-PAD#84 Personally, I don't think it's too bad - vuepress still throws up fairly informative errors on syntax mistakes within the code. You could also do things like using readFileSync to provide the function string |
@leo-buneev I tried out the const fs = require('fs');
const { path } = require('@vuepress/shared-utils');
module.exports = {
plugins: [
['fulltext-search', {
processSuggestions: fs.readFileSync(path.resolve(__dirname, 'processSuggestions.js')),
}],
]
} |
Wow, that looks more complicated than I thought. Later today I'll try to implement option as a regular function (still can't believe it isn't possible 😮), and if I'll be unsuccessfull will merge your PR. |
Yeah I couldn't find a way to "persist" a user-provided function for callback :( |
@leo-buneev For our purposes I've expanded the API in fdeed1f to allow an onclick callback as well - I made the poor choice of opening the PR from a master branch, so please let me know if you would like me to make more granular PRs or just continue expanding on this feature in my fork :) |
Feel free to continue here, it can be considered as part of the same feature |
a850762
to
c9e959d
Compare
@leo-buneev any chance this might land one day? :) We've been running this in https://docs.ubclaunchpad.com with some non-trivial traffic for quite a while, and am quite content with the API defined here. |
@leo-buneev I've cleaned up the PR description and documentation! |
* add support for external links * add processSuggestions API * document fs.readFileSync alternative * expand api to include more functions * support fontmatter search: false * add support for setting query from URL param * remove semicolons for consistency * document search parameters * document excluding pages * improve functions documentation * clean up readme intro * add paths to example blocks * Add support for Japanese * Change naming for functionality added in leo-buneev#10 * Fix leo-buneev#22 * Fix leo-buneev#21 * Fix leo-buneev#2 * Bump version Co-authored-by: Robert Lin <robert@bobheadxi.dev> Co-authored-by: Leonid Buneev <buneev.leonid@gmail.com> Co-authored-by: Leonid Buneev <leonid.buneev@tirecheck.com>
external
results, which opens the result in a new tabfunctions
, which provides an implementable interface for various hooks:processSuggestions
to augment, adjust, or manipulate the suggestionsonGoToSuggestion
to perform actions whenever a result is clickedsearch: false
to exclude a page from resultsquery
for populating and focusing the search bar