Advertisement
dhniceday

IdeaToDailyNote

Jan 14th, 2023
378
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <%*
  2. const ideaHeader = "## Ideas"
  3. const file = tp.file.find_tfile(tp.date.now("YYYY-MM-DD"))
  4. console.log('file: ' + file.name)
  5. var loggedItem = "";
  6. if (file) {
  7.     loggedItem = await tp.system.prompt("Idea to daily note:","",false)
  8.     if (loggedItem !== null && loggedItem !== '') {
  9.         const content = (await app.vault.read(file)).split("\n")
  10.         const index = content.indexOf(ideaHeader)
  11.            
  12.         let addContent = "idea:: " + loggedItem
  13.         content.splice(index + 1, 0 , addContent)
  14.         await app.vault.modify(file, content.join("\n"))
  15.     }
  16. } else {
  17.     new Notice("No daily note found.")
  18. }
  19. -%>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement