omnivore-app / obsidian-omnivore

Obsidian plugin to fetch articles and highlights from Omnivore
MIT License
842 stars 83 forks source link

fix: add a lambda function in the template to allow users to format date #136

Closed sywhb closed 1 year ago

sywhb commented 1 year ago

added a function formatDate to the template which allows users to format a date.

For example, if i want to format dateArchived as yyyy-MM-dd, I could add following to the template:

{{#formatDate}}{{{dateArchived}}},yyyy-MM-dd{{/formatDate}}

The formatDate lambda takes in a string of the date variable and the format which are separated by a comma.

Fixes #119

jacksonh commented 1 year ago

A bit confused with this one. How does a user set it?

sywhb commented 1 year ago

@jacksonh it's a generic way of formatting a date.

For example, in the front matter template, i could format an available date variable to use yyyy-MM-dd format

date-archived: {{#formatDate}}{{{dateArchived}}},"yyyy-MM-dd"{{/formatDate}}

and it will turn out to be

date-archived: 2023-09-29
sywhb commented 1 year ago

Any comment here? @jacksonh