Use a local quote or fortunes file and user script for daily notes #1415
kmaris
started this conversation in
Templates Showcase
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Here's a small user script for a Daily Notes template.
The idea is to pull a quote from a quotes-filled vault file. I use a BSD-style quote file found here. The quote functionality in Templater did not work for me, as the upstream quote api seems flakey. This will also work with no connectivity like if you're on an airplane.
Download a file, or look at how each quote is delimited by lines containing only the '%' character. This script assumes as such, so if you roll your own you must follow that convention for this script to work. Or tweak my script :)
I assume that:
Once you have those, you'll want to create a user script in your vault, as an example I keep mine in
assets/templater-plugin/scripts/fortune.js
. That path is what will be in your templater user scripts plugin settings.The content of
fortune.js
should look roughly like:Important
Please note, I am not a javascript developer. So the code is probably not very good but it only runs once a day, quick enough, and I'm fine with that. Feel free to send me any optimizations or add your own!
After you have the script, go ahead and use it in your daily note template(I put my quote in a code block, as the formatting is sometimes kinda rough). You need to give the user script function the path to your quotes file, like so:
And voila, hopefully you'll have a quote in your daily note.
Beta Was this translation helpful? Give feedback.
All reactions