What I’m trying to do
Hello! I am creating a templater template to allow me to efficiently take literature notes. What I have been unable to do is to code a function to allow me to search within my biblatex references for the right reference to tag the note I am working on. To clarify what I mean, let me explain my setup briefly:
- Biblatex references correspond each to a markdown file in a folder called “references” within my obsidian folder. The name of the markdown file is the same as that of the biblatex key.
- These markdown files that correspond to biblatex references are all tagged in this way:
tags: [reference/book, bibkey/22364ah, etc, etc]
, wherereference
is a tag used to identify the md note as a reference note,book
is the biblatex entry type (book, mvbook, inbook, etc.), and22364ah
is the actual biblatex key for the reference (and also the filename itself). - Following the format of the Obsidian
citations
plugin, my md notes corresponding to biblatex references all have within the YAML properties the usual biblatex fields such asauthor: ["Doe, John"]
,title: "The Greatest Book Ever"
, etc.
With this setup in mind, what I want is this: When creating a new permanent note with templater
I want to be shown a list of my references, so that I can select one so that these are added as tags of the form bibkey/this, bibkey/that, etc
to the permanent note I am creating.
Things I have tried
I was able to get partial success by using this code:
var annotation = (await tp.system.suggester((item) => item.basename, app.vault.getMarkdownFiles(), false, "Select source of annotation/citation")).basename;
With this, I would be shown a list of all md files in my vault so that I can pick up the right one to be assigned to variable annotation
. Then, I use this variable to create the appropriate tag.
Although this function works, it has several limitations I would like to address:
- It searches all the notes and not a specific subset of notes (I would rather search only those tagged “reference” or those in the “references” folder).
- It only shows the note title, but it is difficult to choose the right note without more context. Ideally, I would like it to show some information related to a file from its YAML properties—say, the value for
author
,date
andtitle
(when they’re set) at the very minimum—to make it easier to know what file I am looking for.