But it relies on me editing the notes frequently to update the modification time, otherwise it just provides the same 5 most recently edited notes in a different order.
Is there any way to randomize the results without relying on other variables?
Sounds like you need DataviewJS! You could try something like this:
```dataviewjs
let docs = dv.pages('"FolderName"');
let length = docs.length;
let numberToReturn = 5;
var randos = getRandos(docs, length, numberToReturn);
dv.list(randos);
function getRandos(list, max, itemNum) {
var items = [];
for (var i=0;i<itemNum;i++) {
items.push(list[Math.floor(Math.random() * max)].file.link);
}
return items;
}
You’ll have to replace “FolderName” with the path to your folder of choice.
This code generates five random numbers using Math.random, and it should give you new notes every time you open the document. I tested in my own vault and it seems to work (although duplicates are possible)
(Also you’ll have to turn DataviewJS on in your settings)
@webinspect, is there a way to refine this further to choose a random heading from within a note? I’m trying to streamline a little, and figured if this could be boiled down to choosing from multiple headings in a singular note, instead of having a million different notes it would save heaps of space!
(Thank you again for your previous code, it works like a charm!)
In terms of complexity it would be a whole lot harder, and not as streamlined as the current solution or variation thereof. So I’m not sure it would be a major gain overall to switch to random headings, in fact unless you limit to just one file (or folder) the header variant would create a whole lot more file operations to achieve something similar.