Action
find links to draft
created by @FlohGro / more on my Blog
find links to draft
Searches Drafts that link to the current draft with a [[wiki-style-link]]
.
When one or more Drafts are found a prompt will be displayed to allow you to open those drafts
If you find this useful and want to support me you can donate or buy me a coffe
Steps
-
script
findLinksToDraft(draft) /** * searches for Drafts linking to the given Draft d with wiki-style links. Depending on the amount of found drafts a Prompt will display drafts you can open * @param {Draft} d the Draft you want to find links to */ function findLinksToDraft(d) { let linkText = `[[${d.displayTitle}]]` let foundDrafts = Draft.query(linkText, "all", [], [], "accessed", true, true) if (foundDrafts.length == 0) { app.displayInfoMessage("no links to Draft found") } else if (foundDrafts.length == 1) { // found just one draft let p = new Prompt() p.title = "found 1 draft" p.message = "One Draft found with title \"" + foundDrafts[0].displayTitle + "\"" p.addButton("open") if (p.show()) { editor.load(foundDrafts[0]) } } else { // several drafts found let p = new Prompt() p.title = "found " + foundDrafts.length + " drafts" p.message = "select draft you want to open" foundDrafts.forEach((curDraft) => { p.addButton(curDraft.displayTitle, curDraft) }) if (p.show()) { editor.load(p.buttonPressed); } } }
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.