DEV Community

Discussion on: Source Your Own Daily-Quotes in Obsidian

 
jonasmerlin profile image
Jonas Schumacher • Edited

Thanks for catching that quotes bug! I added the comments when writing the post, not in the original script and didn't test it with them in. I will edit it in the post and add you to the thanks section. 😄

There are multiple ways to make it work with notes anywhere. The easiest would be to simply drop the requirement that the note's name starts with (QUOTE) (or (QUESTION) in your case). This is actually a remnant of the way my own vault is structured and if you will only ever use the #dailyquestion tag with these questions, filtering for it would be enough. You could still name them with a leading (QUESTION), mind you. The problem is simply that folders are appended to the beginning of the name of a note, and since we check the beginning of a note's name for (QUESTION), notes that are in folders get filtered out. These edits should do the trick I think:

if (tags.length > 0) { // list will contain at least one tag for the relevant notes, also filter out all notes"
  questionFiles.push(filename.slice(11, filename.length - 3)) // cuts off "(QUESTION) " AND the last three characters from filename, otherwise the links would contain `.md` at the end
}

// gets the full question title for correct backlinking
if (tags.length) { 
  actualquestionFiles.push(filename.slice(0, filename.length - 3)) 
}
Enter fullscreen mode Exit fullscreen mode

Another way to do it would be to split the note's name on all occurences of / and then use the last element of the resulting list as the "canonical" name of that note. If you'd like a small challange to level up your coding skills, you could try to do this with split() yourself. If you don't - or if you can't seem to make it work - write me and I'll edit the script for you. Nice work on editing it for your usecase btw.! And thanks for sharing, I think I will take inspiration from this for my daily notes as well.

Thread Thread
 
dane_mcneill_b440e54958eb profile image
Dane McNeill

It might be that I am just too new with obsidian to follow these directions. But I can’t get it to work for me. Is the templates folder the same folder as the route folder? I put them in my templates folder hoping that was the case. Also can you provide an example of a quote in text format so I can copy and paste it so when I put that in my templates folder as well I know at least I haven’t coded it incorrectly and that is not the source of my problem.

Finally, how would the solution be modified to put all of the quotes in a folder so they could be organized that way instead of being in a route folder?

Thank you

Thread Thread
 
jonasmerlin profile image
Jonas Schumacher

Hey! Sorry to keep you waiting. This post has gotten a bit long in the tooth I feel and I remember seeing purpose made plugins for this usecase around. (Edit: I think this was it: github.com/decatetsu/local-quotes) So my recommendation would be to use one of those or use the quite elegant solution described here: forum.obsidian.md/t/displaying-a-r...

Should you still have your mind set on using something similar to what I describe in the post - or wanted to use it to get into writing Obsidian scripts - let me know and I'll take a stab at re-understanding and explaining what I came up with there :D

Thread Thread
 
kadena_az profile image
k:soonsoon

Will do. Thanks for the reply!!