Created
August 24, 2021 23:44
-
-
Save GitMurf/9d4d892f6cca1de335316d6072f63f7f to your computer and use it in GitHub Desktop.
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
<%* | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
const files = await app.vault.getMarkdownFiles(); | |
const links = []; | |
files.sort(function(a,b){return b.stat.mtime - a.stat.mtime}); | |
files.forEach(file => { | |
links.push(file.basename); | |
}); | |
const unResLinks = Object.entries(app.metadataCache.unresolvedLinks); | |
unResLinks.forEach((eachLink) => { | |
Object.entries(eachLink[1]).forEach(eachItem => { | |
if(!links.includes(eachItem[0])) { | |
links.push(eachItem[0]); | |
} | |
}); | |
}); | |
const selection = await tp.system.suggester(links, links); | |
search.view.setSortOrder("byCreatedTime"); | |
search.view.setCollapseAll(false); | |
search.view.setExtraContext(true); | |
let myString = selection; | |
myString = myString.replace(/[-[\]{}()+?.,\\^$|#]/g, '\\$&'); | |
search.view.setQuery(`/\\[\\[${myString}(\\]\\]|\\|)/`); | |
app.workspace.revealLeaf(search); | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment