Scheduled surface of quotes (from vault notes) in a daily note

What I’m trying to do

I’d like to transfer my collection of individual quotes to my Obsidian vault, each in a single note. This will allow me to do two things:
1.) Expand on the quote as a source note
2.) At a scheduled date, surface the quote and attribution in my daily note, Canvas Dashboard, etc.

Things I have tried

I have used the following YAML as a template for each quote.

---
attribution: W. C. Fields
category:
  - Humor
comments: 
quoteTitle: Try, try, try again...
quoteText: If at first you don't succeed, try, try again. Then quit. No use being a damn fool about it.
source: Unkown
subject: Persistence
surfaceDate:
  - 2024-05-09
tags:
  - quote
url:
---

Using the Meta Bind Plugin I’ve successfully placed a Quote callout in the body of the note to start off the note using YAML as the source.

> [!quote] `VIEW[{quoteTitle}]`
> `VIEW[{quoteText}]`
> 
>    – `VIEW[{attribution}]`

Next, what would be ideal is when a daily note is created using a template, I would like to use the date of the daily note to find the matching quote and add it in a fashion of the callout above. The criteria will be:

  1. The scheduled date (should match the date of the daily note)
  2. The Topic ( I might have a particular topic to surface on a particular day.)

I ‘ve searched Dataview, read the manual, and looked for other examples. There are a lot that query services using APIs or a single note with a list of quotes, but none that will query a collection of quote notes and surface on a specific day.

Any help would be greatly appreciated.

I think there may be a plugin that does something like this.

There’s one called “Review” (found by searching “future”). There may be others.

Thanks for suggestion, but it that plugin appears to just to set up a queue for spaced repetition of a set of notes.

I’d like to be able to retrieve a quote/note on a particular day and embed it in a daily note.

EDIT
———
I just found the one by Ryan J Murphy called Review, which looks promising! I’ll report back.

For some reason, I found obsidian-simple-note-review first, which might be useful later.

Yeah, Ryan’s is the one I was suggesting.

I checked out the plugin Review and it’s interesting, but it means I would have to manually touch every quote file, which would be painful. I can use a bash script to quickly generate the Markdown files and the hope is that I should be able just to find the one I need when I need it.

I’ve opted to try and learn Templater and DataviewJS.

I figured I might as well learn something new and it looks like for a first timer I got something working.

My test notes have the following YAML:

---
attribution: W. C. Fields
comments: 
quoteCategory: Humor
quoteTitle: "Try, try, try again..."
quoteText: "If at first you don't succeed, try, try again. Then quit. No use being a damn fool about it."
source: Unknown
subject: Persistence
surfaceDayOfYear: 152
url:
---

---
attribution: "Anonymous"
comments: 
quoteCategory: Humor
quoteTitle: "A Funny Quote"
quoteText: "Laughter is the best medicine."
source: Unknown
subject: Persistence
surfaceDayOfYear: 152
---

The following dataview code block finds all notes that have a quoteCategory of “Humor” and a surface day of today. It can be modified for different categories or none just to get all of the quotes of the day.

dataviewjs
const currentDate = new Date();
const start = new Date(currentDate.getFullYear(), 0, 0);
const diff = currentDate - start;
const oneDay = 1000 * 60 * 60 * 24;
const currentDayOfYear = Math.floor(diff / oneDay);

// Perform the Dataview query
dv.table(
  ["quoteTitle", "quoteCategory", "quoteText", "attribution", "surfaceDayOfYear"],
  dv.pages()
    .where(p => p.surfaceDayOfYear == currentDayOfYear && p.quoteCategory == "Humor")
    .map(p => [p.quoteTitle, p.quoteCategory, p.quoteText, p.attribution, p.surfaceDayOfYear])
);

The following Templater code will find any note with the surfaceDayOfYear of today (current day of the year (1-366)) with a quoteCategory of “Humor”, “Inspiration”, or “Wisdom” (these can be changed or added to as desired) and add the quotes in separate quote callouts in the current note. There’s a lot of calls to log results in the console as I was testing.

<%*
const currentDate = new Date();
const start = new Date(currentDate.getFullYear(), 0, 0);
const diff = currentDate - start;
const oneDay = 1000 * 60 * 60 * 24;
const currentDayOfYear = Math.floor(diff / oneDay);

console.log(`Current Day of Year: ${currentDayOfYear}`);

const quoteCategories = ["Humor", "Inspiration", "Wisdom"];
const quotes = {};

const dv = app.plugins.plugins["dataview"].api;

for (const category of quoteCategories) {
    const query = `
    TABLE without id quoteTitle, quoteCategory, quoteText, attribution, surfaceDayOfYear
    WHERE surfaceDayOfYear = ${currentDayOfYear} AND quoteCategory = "${category}"
    `;
    console.log(`Running query for category: ${category}`);
    console.log(query);

    const categoryQuotes = await dv.query(query);
    console.log(`Results for category ${category}:`, categoryQuotes);

    if (categoryQuotes && categoryQuotes.value && categoryQuotes.value.values.length > 0) {
        // Extract the first result
        const firstQuote = categoryQuotes.value.values[0];
        quotes[category] = {
            quoteTitle: firstQuote[0],
            quoteCategory: firstQuote[1],
            quoteText: firstQuote[2],
            attribution: firstQuote[3],
            surfaceDayOfYear: firstQuote[4]
        };
    } else {
        console.log(`No quotes found for category: ${category}`);
    }
}

let output = "";
for (const category of quoteCategories) {
    if (quotes[category]) {
        const quote = quotes[category];
        output += `> [!quote] ${quote.quoteTitle}\n`;
        output += `> ${quote.quoteText}\n`;
        output += `> —— ${quote.attribution}\n\n`;
    } else {
        output += `> [!quote] No ${category} quote for today.\n\n`;
    }
}
tR = output
%>

I like this solution because:

  1. It gives me the flexibility to have quotes as source notes to which I can add thoughts and backlinks.
  2. I can render the notes anywhere (Daily Notes, Canvas Dashboards, etc.) and with one piece of Templater code.)
  3. I can have a dynamic list of the notes (MOC) using Dataview.

I’ve never used Templater or Dataview and this is my first go. I am very open to suggestions about tweaking or alternate ways of doing this.