I have a problem with upgrading my custom quote system.
I have a note called “Wisdom nuggets.md” that contains simple quotes like this:
First wisdom nugget
Second wisdom nugget
Third wisdom nugget…
I also have a Templater template set up so that it fetches “Wisdom nuggets.md” splits into each quote and then randomly selects one of them to display as a quote like this:
Second wisdom nugget
— Wisdom nugget
It works fine.
Sometimes when I see the quote I want to change it in some way so I want to extend this system so that instead of getting a raw copy of the quote’s text, I get a link to that quote inside the “Wisdom nuggets.md”.
I know about block links and the
![[...]] embedded links. I also know how to generate a link to an existing
^blockID with Templater.
I don’t want to manually micromanage if every single line in “Wisdom nuggets. md” has a
^blockID. The quotes in “Wisdom nuggets.md” can be added to the file in various ways. I write them there manually, I use the Note Refactor plugin, I copy-paste them, and I expect more ways to come in the future. I do not find the idea of manually adding
^blockID every time something gets added to the file acceptable.
Whenever I run the Templater template, if it finds a quote without a
^blockID, it adds it generates one, and adds it to the file “Wisdom nuggets.md”
This requires that the check and the generation of new
^blockID happen from anywhere I would want to fetch a quote. This violates the DRY principle and I would like to avoid that.
Whenever the “Wisdom nuggets.md” file is modified, something finds all quotes without a
^blockID and then generates and adds them. This sounds like a much better idea but I do not know what that something is. Is there something, that can react to the file being modified?
I noticed that when I write
[[Wisdom nuggets#^]] Obsidian gives me suggestions on everything, that is or could be a block link and auto generates
^blockID if there is none. Is there a way I could use this function with Templater? How would I do it?
It would be nice to sidestep the need to parse the file, check if there is a
^blockID on each line, and then generate some unique
So in the end the question is, can you help me find a better solution than checking every time any template wants to get a quote and replicating the code for every template that does that?