What I’m trying to do
Hello, I would like to rewrite my dataviewjs script to pull only from a subfolder, not any notes from the main folder or other subfolders. I have this setup for inspirational quotes to randomly appear on my homepage and I thought I’d like to see art appear as well (on another page I’ll have in the sidebar). Here’s my current setup, with examples of the random output.
“Homepage” file has a custom callout that has an imaged Wikilink to the “Inspirational Quote” file which has a dataviewjs script that pulls random notes from my “Inspirational” folder, except the “Inspirational Quote” file itself, and now two subfolders (might be convoluted but works for me!).
const notes = dv.pages('"Inspirational"').where(page => !page.file.path.includes('Inspirational/Art', 'Inspirational/Book Notes', 'Inspirational/Inspirational Quote'));
const randomNote = notes[Math.floor(Math.random() * notes.length)];
dv.span(`**![[${randomNote.file.name}]]**`);
dv.span(`[[${randomNote.file.name}|Source]]`);
I had written this script using AI, begrudgingly, because I don’t know Javascript well and Google is not what it used to be… (I think I referenced this forum at the time, too.) I still had to use multiple prompts from a couple AIs, and frankenstein the result to this (and look up how to use span since neither OpenAI nor DeepSeek gave that).
Things I have tried
Now I want to rewrite this script to pull only from the “Inspirational/Art” subfolder. I messed around the first line and I just can’t seem to do it myself, I don’t know where I’m going wrong to only get errors. And AI is no longer free to prompt over and over, and Google is still as frustrating as ever now.
Any help would be much appreciated!
