You can read a longer write up on my blog.
HydraShard is a Which-key for Neovim/Hydra for Emacs replacement for Obsidian
Simply make available the hydra.js script available in your Templater user script folder.
After that you can simply call it with:
tp.user.hydra(menuitems)
Where menuitems
is an objct of the following shape
let menuitems = [
{
key: "f",
name: "Name to be displayed here",
action: async () => {
let var = await tp.user.someModule();
return var;
},
},
{...}
]
You need to pass the tp
object in order to access other user scripts.
HydraShard
captures the return value of the triggered function so you can define your behavior both in and out of menuitems
.
let result = tp.user.hydra(menuitems)
let capturedOutput = result.result
// Do anythign with capturedOutput here
There are several strategy depending on how you want to split your code and how much you want to re-use your functions, look at the examples folder.