Hello,
I’m quite new to obsidian, but I’m really loving it. I’m using it to organize my stand-up comedy material, linking my jokes to one another.
In my repository I’ve saved all my jokes as individual files, and each file (i.e., a joke) has a bullet list of links called “Follow-ups” that links that joke to the one that should come afterward.
I’ve built a script with templater, to help me create set lists (an organized list of the jokes I’m planing to use during a show) that uses a suggester to show me all my jokes and allow me to pick them and add them as links to my set list file. I would like to improve it, limiting the options this suggester proposes me every time, to only files linked as “Follow-ups” (so basically any outgoing link in the file) in the last picked file.
Currently, the script just shows me the full list of files, removing the selected ones each time.
Can anyone help?
Thanks
<%*
function getTags(file) { const metadata = app.metadataCache.getFileCache(file); return metadata.tags ? metadata.tags.map(tag => tag.tag) : []; }
let allFiles =app.vault.getMarkdownFiles().filter(file => !file.path.match("/")); //Files in the root folder will not
let selectMore = true
let selectedFiles = []
while (selectMore) {
let choice = await tp.system.suggester((item) => `${item.basename} (Tags: ${getTags(item).join(' ')})`, allFiles, false, "[Select files (ESC when finished)] - " + selectedFiles.join(", "))
if (!choice)
{
selectMore = false
}
else
{
selectedFiles.push(choice.basename)
allFiles = allFiles.filter(file => !file.path.match(choice.basename))
}
}
selectedFiles.forEach((selectedFile) => {
tR += '\n - [[' + selectedFile + ']]';
})
tR += "\n ----- \n"
_%>