If you’re from Obsidian and have used the Templater plugin, you may have utilised the tp.web.dailyquote() module to pull a daily quote into your journal etc.
I quickly knocked up the following space-script to bring that functionality into SB using the same Quotables API as Templater:
silverbullet.registerFunction({name: "dailyQuote"}, async () => {
const quoteAPI = 'https://api.quotable.io/quotes/random';
const response = await fetch(quoteAPI);
if (!response.ok) {
throw new Error('Failed to fetch quote');
}
const data = await response.json();
const quoteData = Array.isArray(data) ? data[0] : data;
if (quoteData.content && quoteData.author) {
const quote = quoteData.content;
const author = quoteData.author;
const formattedQuote = `${quote}\n> — ${author}`;
return formattedQuote;
} else {
throw new Error('No quote in response');
}
})
I then use a custom admonition borrowed from the Additional Admonition Types post, to insert it into my daily journal template.
> **quote** Today's Quote
> {{dailyQuote}}
The script uses the random endpoint to select from the entire Quotables database. If you’d only like to see specific tags, update const quoteAPI
to reduce the scope, for example: /quotes/random?tags=technology,famous-quotes
.
I am bumbling my way through this as I’m not a developer, so if there is something to improve, do let me know.