omnivore-app / obsidian-omnivore

Obsidian plugin to fetch articles and highlights from Omnivore
MIT License
737 stars 39 forks source link

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

Closed sywhb closed 8 months ago

sywhb commented 9 months 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 9 months ago

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

sywhb commented 9 months 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 8 months ago

Any comment here? @jacksonh