Last active
April 8, 2022 15:17
-
-
Save luckman212/be490b8751e7f9f87146a9c260b9f7bc to your computer and use it in GitHub Desktop.
Templater: Insert current search as a markdown link
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%* | |
var searchLeaf; | |
app.workspace.iterateAllLeaves(leaf => { | |
if (leaf.view.getViewType() === 'search') { | |
searchLeaf = leaf; | |
}}); | |
if (typeof(searchLeaf) !== 'undefined') { | |
var q = searchLeaf.view.getQuery(); | |
if (q !== '') { | |
var md = '[search: ' + q + '](obsidian://search?query=' + encodeURIComponent(q) + ')'; | |
tR += md; | |
} else { | |
new Notice('Search field is empty!'); | |
} | |
} | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment