This is an (in-progress) infobox for Trilium Next Notes.
- Create a new note somewhere (preferably under a
Scripts
note or something to keep everything organized) - Create a new note called
Infobox
- Create a new note under
Infobox
calledtemplate
and make theNote Type
HTML
- Create a new note under
template
and call itjs
and make theNote Type
JS Frontend
- Create two new notes under
js
. Call the first onedayjs_plugin_relativeTime
and call the second onedayjs_plugin_advancedFormat
. Set bothNote Type
s toJS Frontend
- Add a new Relation to the
Infobox
note (not thetemplate
note!). The Name will berenderNote
and the Target Note will be thetemplate
you created in step 3. This tells Trilium to render the HTML, instead of just displaying the raw text
At this point, your folder structure should look like this:
Scripts or wherever you're storing this
└── Infobox (Type: Render Note)
└── template (Type: HTML)
└── js (Type: JS Frontend)
├── dayjs_plugin_relativeTime (Type: JS Frontend)
└── dayjs_plugin_advancedFormat (Type: JS Frontend)
- Copy and paste the code from
template.html
in this gist into thetemplate
note you created in step 3 - Copy and paste the code from
js.js
in this gist into thejs
note you created in step 4 - Copy and paste the code from this file into the
dayjs_plugin_advancedFormat
note you made in step 5 - Copy and paste the code from this file into the
dayjs_plugin_relativeTime
note you made in step 5
Now you have all the files you need to get started.
This relies on three labels, DateOfBirth
, DateOfDeath
and Address
. It's best to add them to a template note so you don't have to recreate them every time. My label code looks like this:
#label:DateOfBirth(inheritable)="promoted,alias=Date of Birth,single,date" #label:DateOfDeath(inheritable)="promoted,alias=Date of Death,single,date" #label:Address(inheritable)="promoted,alias=Address,single,text"
- Go to the note you want to add this to or create a new note with those three labels
- Use the
Include Note
button in the toolbar and add your Infobox note:
This is a work in progress. It may throw up errors or not work entirely. It currently doesn't work with multi-value labels, and there may be much better ways to accomplish this, but it works for my needs.
I'm using DayJS's "Relative Time" plugin and it doesn't give you any nuance because I guess they figure people don't really care too much about specifics (e.g. "Six months ago" or "1 day from now" is fine), but for dates of birth and such, I'd say it'd be nice to be accurate. I'll look and see if there's a way to get more specific with it (e.g. "24 years and 3 months") but it might involve using something other than DayJS (which is built into Trilium)
I'll look into that as well. There's some scripting examples that work with Trilium's SQL to do things like find the most linked notes.
At some point I might move this to a dedicated repo so people can just import it from Trilium, no manual steps required, but I'll see how I go, as this is mostly for a personal project I've been planning for years, so it might end up just supporting features I need, but be open source so people can tweak it.