Created
February 9, 2022 09:03
-
-
Save GitMurf/d81686d1c5983d2ae8cbabaa7e9c2a1b 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 myDnpPath = 'dnp'; | |
let dueDateStr = await tp.system.prompt("Enter Date to Start from", "Today"); | |
const daysBackStr = await tp.system.prompt("How many days back?", "7"); | |
const daysBack = parseInt(daysBackStr); | |
let parseResult; | |
let parseResultLink; | |
const getAllDates = []; | |
if(dueDateStr) { | |
let nlDatesPlugin = app.plugins.getPlugin('nldates-obsidian'); | |
parseResult = nlDatesPlugin.parseDate(dueDateStr); | |
if(parseResult){parseResultLink = parseResult.formattedString;} | |
if(parseResultLink) { | |
for ( let i = 0; i < daysBack; i++ ) { | |
let newDate = tp.date.now("YYYY-MM-DD", (-1 * i), parseResultLink); | |
const foundDnp = app.vault.getAbstractFileByPath(`${myDnpPath}/${newDate}.md`); | |
if(foundDnp){getAllDates.push(foundDnp)} | |
} | |
} | |
} | |
let finalString = "# Embedding Daily Notes Pages"; | |
if(parseResultLink && getAllDates.length > 0) { | |
const thisLeaf = app.workspace.activeLeaf; | |
for (const eachDay of getAllDates) { | |
finalString = `${finalString}\n\n## ${eachDay.basename}\n\n![` + `[${eachDay.basename}]]`; | |
} | |
} | |
tR = finalString; | |
%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment