Found custom commands setting in config.edn recently, want to use it to fetch in variables’ values, is it possible to do that?
;; Add your own commands to speedup.
;; E.g. [["js" "Javascript"]]
:commands [ ]
For examples, I want to make a command called “wiki”, and when I type <wiki then press Enter, it will give me such an input :[Wikipedia](https://en.wikipedia.org/wiki/[page name here]. In short, I want to make a command that go straight to a web url using variables like current page name. I can’t use template macros because <%current page%> always attaches a [[]] in return which will break the search parameter.
So I tested patterns like advanced queries but it didn’t work. Just some imitative and intuitional trying like:
@hkgnp Thanks for the work! It does help in a particular way.
I noticed two sentences in readme:
“Button templates can be used within a Logseq template if you prefer.”
" <%PB:time%> Inserts a powerblock in your template, e.g. “time”. This only works for buttons."
Does it mean I can use <%PB:name%> to call up custom PBtemplate in Logseq System template?
Or just use this in PB normal template because the expression bias?
Anyway the main problem I see with this idea in general is that <%current page%> gives the title of the page with spaces, while Wikipedia uses _ instead of spaces in its URLs. So @Roby_Ho are you using page names like [[Foo_bar]] or am I missing something?
Nice try, and the idea about macros. But if could use <%current page%> then can actually use it in Logseq system template, which supports <%current page%> too.
The point is, <%current page%> always returns a string with a double square bracket [[ ]], this will be included in search parameter and make it wrong, need take time to manually carefully adjust it.
About the space, you can add [ ]( ) to avoid it.
E.g. a compromise, right now I use logseq-powerblocks-plugin by @hkgnp , create a powerblock template in a page, like this:
- wiki #powerblocks
- [<%CURRENTPAGENAME%> - Wikipedia](https://zh.wikipedia.org/wiki/<%CURRENTPAGENAME%>)
For now it can be used by typing /insert powerblock, for more instinctively use I copy its button renderer to custom command in config.edn:
Now if you type /wiki anywhere then Enter, it will pop up a white “powerblock button”, then click it manually, it will return a link in format []() and it can handle the spaces correctly.
It’s a compromise way, still, expecting a native way to solve this.
@cannibalox Wow, took a quick trying. This plugin is perfect! And thanks the intro for wikiwand.com and iframe, that’s new to me, will take some time to make a little research though
Update: But this will cause another problem. This plugin seems like can only clear anything in the original block to render. It means if I use it in a page property block, it will clear anything originally which is the page properties.
But this seems like a changeable config, I will write an issue to see what’s going on.