Created
September 23, 2021 19:50
-
-
Save GitMurf/09e78ba81508d1f02de7fb315a06e536 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
<%* | |
let dueDateStr = await tp.system.prompt("Enter Date", "Tomorrow"); | |
let parseResult; | |
let parseResultLink; | |
if(dueDateStr) { | |
let nlDatesPlugin = this.app.plugins.getPlugin('nldates-obsidian'); | |
parseResult = nlDatesPlugin.parseDate(dueDateStr); | |
if(parseResult){parseResultLink = parseResult.formattedString;} | |
} | |
if(parseResultLink) { | |
const search = app.workspace.getLeavesOfType("search")[0]; | |
search.view.setSortOrder("byCreatedTime"); | |
search.view.setCollapseAll(false); | |
search.view.setExtraContext(true); | |
const dnp = parseResultLink; | |
const dnp2 = dnp.replace(/-/g, `_`); | |
//looking for backlinks only | |
let finalQuery = `/\\[\\[${dnp}(\\]\\]|\\|)/`; | |
//Optional - looking for date with underscores too | |
finalQuery = `${finalQuery} OR /${dnp2}/`; | |
//Optional - looking for file name with date in it | |
finalQuery = `${finalQuery} OR file:(${dnp})`; | |
//Optional - exclude weekly review and today DNP | |
finalQuery = `(${finalQuery}) -file:(/^${dnp}[^a-zA-Z0-9_]/) -file:("weekly review")`; | |
//Add query to search | |
search.view.setQuery(finalQuery); | |
app.workspace.revealLeaf(search); | |
} | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment