Hi all,
I tried, but failed, to find a good way to add a given number of links to random notes in a given folder (my 2nd brain notes) to my daily note. I’d like to add these links to my daily notes as a way to force myself to review a certain number of notes every day.
Is there a way to implement this? I’m certain it should be possible with JS in templater, but I can’t seem to get the paths right.
@dhniceday this is great. Is there a way to not have it generate a new random link every time I accidentally enter the code in edit mode? I.e. generate the randomNote variable only once.
Unfortunately, that is not the case for me. I added the code to a template that is loaded when a new daily note is generated. However, this will still change the link every time I reopen the daily note or switch between read and edit view.
Templater can run in different modes, and can do various stuff in those modes, one of them, the Javascript Execution Commands, using <%* to start the template block, allows for javascript execution, and it has a special way of doing output.
In this mode, you can append stuff to the new note by appending text to the tR variable, like you see in the last line of my template. More info on this, and other modes, can be seen here: Execution Commands - Templater