Buttons on Daily note with different purposes

Hi folks,

Quite a rudimentary user here, so please bear with me if this is a stupid question.

What I’d like to do

I’d like to add two buttons to my daily note template:

  1. One that generates into a new tab a random note from certain folders in my vault (I’d like to exclude my templates folder and my inbox, for example).
  2. Another that generates in to a new tab a random note which is within my vault but is unlinked to other notes.

What I have tried

I already have a link in my Daily Note template to generate a random note:

<%*
const noOfNotes = 1
const dv = this.DataviewAPI
const files = await dv.tryQuery(`
  LIST
  FROM #quote 
`)

let randomList = []

for (let i = 0; i < noOfNotes; i++) {
  const random = Math.floor(Math.random() *
                            (files.values.length - 1))
  randomList.push(files.values[random])
}

tR += dv.markdownList(randomList)
%>

The trouble with that query is that it creates a link to the random note back to my daily note. I don’t want that. I just want the note with the link back. I have the button generator community plug in, but can’t fathom how to combine the two requests.

I assume the second request could be achieved by a Dataview query, but again I am unsure how to link that to a button. I suppose this could also be achieved with a simple query in the daily note template.

I would be very grateful for guidance from some kind soul!

Thanks!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.