Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Nov 6, 2023

Conversation

sywhb
Copy link
Collaborator

@sywhb sywhb commented Sep 28, 2023

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

@sywhb sywhb removed the request for review from rupin90 September 28, 2023 07:19
@jacksonh
Copy link
Contributor

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

@sywhb
Copy link
Collaborator Author

sywhb commented Sep 29, 2023

@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 sywhb changed the base branch from master to develop October 2, 2023 03:48
@sywhb
Copy link
Collaborator Author

sywhb commented Oct 25, 2023

Any comment here? @jacksonh

@sywhb sywhb force-pushed the fix/add-function-to-format-date branch from 0978aae to 74b2114 Compare November 6, 2023 04:22
@sywhb sywhb merged commit be1119b into develop Nov 6, 2023
12 checks passed
@sywhb sywhb deleted the fix/add-function-to-format-date branch November 6, 2023 04:23
sywhb added a commit that referenced this pull request Nov 6, 2023
…ate (#136)

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

* return empty string if date variable is undefined in the formatDate function
github-actions bot pushed a commit that referenced this pull request Nov 6, 2023
## [1.7.1](1.7.0...1.7.1) (2023-11-06)

### Bug Fixes

* add a lambda function in the template to allow users to format date ([#136](#136)) ([fb961e7](fb961e7))
github-actions bot pushed a commit to someskumar-k/obsidian-omnivore-educative that referenced this pull request Aug 13, 2024
# 1.0.0 (2024-08-13)

### Bug Fixes

* add a lambda function in the template to allow users to format date ([omnivore-app#136](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/136)) ([fb961e7](fb961e7))
* add a reset template button to reset the template to default template ([06df987](06df987))
* add a setting to disable sync on start ([omnivore-app#198](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/198)) ([d9c5fb2](d9c5fb2))
* add available variables to the template config description ([09f8c83](09f8c83))
* add back the ribbon icon for the ease of usage ([f1e9eeb](f1e9eeb))
* add date_published in the frontmatter ([cf61925](cf61925))
* add dateArchived to the exposed variable in the template ([1a67d16](1a67d16))
* add dateRead variable in the article template ([8141166](8141166))
* add image to the variables of article template ([0941dc2](0941dc2))
* add labels of highlights to the template ([4b8aee1](4b8aee1))
* add lowercase, uppercase and uppercasefirst to the function map in the template ([957bbca](957bbca))
* add note variable to the template ([ea65aa6](ea65aa6))
* add state to the exposed variable in the template ([26572b6](26572b6))
* add tweet, video and image page type ([ffdcd92](ffdcd92))
* add type to the template ([e04f7ab](e04f7ab))
* add updatedAt variable to the article template to get the last u… ([omnivore-app#183](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/183)) ([05079e1](05079e1)), closes [omnivore-app#176](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/176) [omnivore-app#187](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/187)
* add wordsCount and readLength to the exposed variables in the article template ([56813b7](56813b7))
* allow adding aliases to the variables in the front matter ([be1d7e5](be1d7e5))
* allow articles to be synced into a single file and add a toggle in the settings ([4c04f8e](4c04f8e))
* allow frontmatter to be an array ([2b3b0f3](2b3b0f3))
* allow scheduled sync and set a frequency in minutes ([8800d38](8800d38))
* better name for Sync on Start in settings ([93fe7e9](93fe7e9))
* create an omnivore file for an existing TFolder ([b7768ff](b7768ff))
* download content and file attachment only if included in the template ([dc92a38](dc92a38))
* failed to fetch highlight when quote is null ([2dc2fcc](2dc2fcc))
* failed to save note in windows by removing invisible characters in the filename ([cf99fc5](cf99fc5))
* failed to sync articles to an existing file without front matter ([58dbf98](58dbf98))
* file already exists error caused by having duplicate article titles ([8dec30f](8dec30f))
* folder path separators are incorrectly replaced ([5d6bf4f](5d6bf4f)), closes [omnivore-app#219](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/219)
* generate unicode slug as file name ([2e5fcd6](2e5fcd6))
* highlight color not available in the template ([e90807d](e90807d))
* incorrect highlight position by incorrectly using highlight position percentage which old highlights do not have it ([76a120f](76a120f))
* invalid yaml error when generating the front matter ([10a9b96](10a9b96))
* lint code in CI ([omnivore-app#161](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/161)) ([460c489](460c489))
* make description available in the template ([b8760a2](b8760a2))
* make siteName and other variables in the article template available in the folder/file name settings ([omnivore-app#190](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/190)) ([6329bb3](6329bb3))
* make the settings collapsible ([71da2c2](71da2c2))
* only add omnivore id to the frontmatter if frontmatter is not in the template ([f46b4fc](f46b4fc))
* PDF page numbers start at 1 ([omnivore-app#155](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/155)) ([c69459c](c69459c))
* potential issues with new release in the community market based on the feedback from Obsidian team ([d987f21](d987f21))
* preparse template before rendering ([c41bc8f](c41bc8f))
* remove content from default template ([11a0202](11a0202))
* replace all empty lines with blockquote ">" to preserve paragraphs ([e02e5de](e02e5de))
* replace all reserved characters in filename with - ([582beb3](582beb3))
* ribbon icon stroke color does not match the theme color ([dbe46a8](dbe46a8))
* search content was returned if we are syncing a pdf ([3c10e1a](3c10e1a))
* show release notes after upgrade ([37382a2](37382a2))
* some highlighted markdown content not synced ([bc84e26](bc84e26))
* sort highlights by position percentage if available ([4a614c7](4a614c7))
* sub-folder can be config in folder name setting and {{date}} can be used ([57a45e5](57a45e5))
* test ([815238c](815238c))
* truncate filename length to 100 ([12ebcf7](12ebcf7))
* unicode in filename is deleted ([1c7458a](1c7458a))
* update filter setting will update custom query accordingly and default to in:all ([omnivore-app#196](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/196)) ([f443aee](f443aee))
* Update link to search in docs ([558cdc4](558cdc4))
* update sync_at once sync is completed ([9b7e289](9b7e289))
* use default template if empty ([7b4f7e4](7b4f7e4))
* use labels names as tags in the front matter ([0341a4e](0341a4e))
* use multiline string for title and author in default template ([c7e5daf](c7e5daf))
* use omnivore title as the filename and add omnivore id to the frontmatter which is used to deduplicate files with the same name ([8fbf85d](8fbf85d))
* wrap value in frontmatter with double quotes ([3f996fd](3f996fd))
* wrong base url in the api request ([432a404](432a404))

### Features

* add a optional front matter template under advanced settings ([afde987](afde987))
* add date format configuration for filename variable ([f1f0a2d](f1f0a2d))
* add link to our discord server in the settings ([5c3df3d](5c3df3d))
* add more variables in the front matter setting ([942b93e](942b93e))
* allow dataPublished and dateSaved to be used as filename ([22046e3](22046e3))
* allow dataPublished and dateSaved to be used as folder name with folder date format ([3f8fb56](3f8fb56))
* custom filenames ([650a9ad](650a9ad))
* download pdf in attachment folder and expose a variable {{{pdfAttachment}}} in the template ([bed8835](bed8835))
* expose positionPercent and positionAnchorIndex variables in highlight template ([omnivore-app#150](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/150)) ([fa3bd32](fa3bd32))
* highlight highlights in the exported content in markdown ([6cc1b04](6cc1b04))
* Now I can delete article from omnivore!!! ([3715beb](3715beb))
* render highlight color in article note ([c8a4e70](c8a4e70))
* start to sync when plugin is loaded ([omnivore-app#170](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/170)) ([280f027](280f027))
* use id as filename ([omnivore-app#154](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/154)) ([74e255a](74e255a))
github-actions bot pushed a commit to someskumar-k/obsidian-omnivore-educative that referenced this pull request Aug 13, 2024
# 1.0.0 (2024-08-13)

### Bug Fixes

* add a lambda function in the template to allow users to format date ([omnivore-app#136](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/136)) ([fb961e7](fb961e7))
* add a reset template button to reset the template to default template ([06df987](06df987))
* add a setting to disable sync on start ([omnivore-app#198](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/198)) ([d9c5fb2](d9c5fb2))
* add available variables to the template config description ([09f8c83](09f8c83))
* add back the ribbon icon for the ease of usage ([f1e9eeb](f1e9eeb))
* add date_published in the frontmatter ([cf61925](cf61925))
* add dateArchived to the exposed variable in the template ([1a67d16](1a67d16))
* add dateRead variable in the article template ([8141166](8141166))
* add image to the variables of article template ([0941dc2](0941dc2))
* add labels of highlights to the template ([4b8aee1](4b8aee1))
* add lowercase, uppercase and uppercasefirst to the function map in the template ([957bbca](957bbca))
* add note variable to the template ([ea65aa6](ea65aa6))
* add state to the exposed variable in the template ([26572b6](26572b6))
* add tweet, video and image page type ([ffdcd92](ffdcd92))
* add type to the template ([e04f7ab](e04f7ab))
* add updatedAt variable to the article template to get the last u… ([omnivore-app#183](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/183)) ([05079e1](05079e1)), closes [omnivore-app#176](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/176) [omnivore-app#187](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/187)
* add wordsCount and readLength to the exposed variables in the article template ([56813b7](56813b7))
* allow adding aliases to the variables in the front matter ([be1d7e5](be1d7e5))
* allow articles to be synced into a single file and add a toggle in the settings ([4c04f8e](4c04f8e))
* allow frontmatter to be an array ([2b3b0f3](2b3b0f3))
* allow scheduled sync and set a frequency in minutes ([8800d38](8800d38))
* better name for Sync on Start in settings ([93fe7e9](93fe7e9))
* create an omnivore file for an existing TFolder ([b7768ff](b7768ff))
* download content and file attachment only if included in the template ([dc92a38](dc92a38))
* failed to fetch highlight when quote is null ([2dc2fcc](2dc2fcc))
* failed to save note in windows by removing invisible characters in the filename ([cf99fc5](cf99fc5))
* failed to sync articles to an existing file without front matter ([58dbf98](58dbf98))
* file already exists error caused by having duplicate article titles ([8dec30f](8dec30f))
* folder path separators are incorrectly replaced ([5d6bf4f](5d6bf4f)), closes [omnivore-app#219](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/219)
* generate unicode slug as file name ([2e5fcd6](2e5fcd6))
* highlight color not available in the template ([e90807d](e90807d))
* incorrect highlight position by incorrectly using highlight position percentage which old highlights do not have it ([76a120f](76a120f))
* invalid yaml error when generating the front matter ([10a9b96](10a9b96))
* lint code in CI ([omnivore-app#161](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/161)) ([460c489](460c489))
* make description available in the template ([b8760a2](b8760a2))
* make siteName and other variables in the article template available in the folder/file name settings ([omnivore-app#190](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/190)) ([6329bb3](6329bb3))
* make the settings collapsible ([71da2c2](71da2c2))
* only add omnivore id to the frontmatter if frontmatter is not in the template ([f46b4fc](f46b4fc))
* PDF page numbers start at 1 ([omnivore-app#155](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/155)) ([c69459c](c69459c))
* potential issues with new release in the community market based on the feedback from Obsidian team ([d987f21](d987f21))
* preparse template before rendering ([c41bc8f](c41bc8f))
* remove content from default template ([11a0202](11a0202))
* replace all empty lines with blockquote ">" to preserve paragraphs ([e02e5de](e02e5de))
* replace all reserved characters in filename with - ([582beb3](582beb3))
* ribbon icon stroke color does not match the theme color ([dbe46a8](dbe46a8))
* search content was returned if we are syncing a pdf ([3c10e1a](3c10e1a))
* show release notes after upgrade ([37382a2](37382a2))
* some highlighted markdown content not synced ([bc84e26](bc84e26))
* sort highlights by position percentage if available ([4a614c7](4a614c7))
* sub-folder can be config in folder name setting and {{date}} can be used ([57a45e5](57a45e5))
* test ([815238c](815238c))
* truncate filename length to 100 ([12ebcf7](12ebcf7))
* unicode in filename is deleted ([1c7458a](1c7458a))
* update filter setting will update custom query accordingly and default to in:all ([omnivore-app#196](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/196)) ([f443aee](f443aee))
* Update link to search in docs ([558cdc4](558cdc4))
* update sync_at once sync is completed ([9b7e289](9b7e289))
* use default template if empty ([7b4f7e4](7b4f7e4))
* use labels names as tags in the front matter ([0341a4e](0341a4e))
* use multiline string for title and author in default template ([c7e5daf](c7e5daf))
* use omnivore title as the filename and add omnivore id to the frontmatter which is used to deduplicate files with the same name ([8fbf85d](8fbf85d))
* wrap value in frontmatter with double quotes ([3f996fd](3f996fd))
* wrong base url in the api request ([432a404](432a404))

### Features

* add a optional front matter template under advanced settings ([afde987](afde987))
* add date format configuration for filename variable ([f1f0a2d](f1f0a2d))
* add link to our discord server in the settings ([5c3df3d](5c3df3d))
* add more variables in the front matter setting ([942b93e](942b93e))
* allow dataPublished and dateSaved to be used as filename ([22046e3](22046e3))
* allow dataPublished and dateSaved to be used as folder name with folder date format ([3f8fb56](3f8fb56))
* custom filenames ([650a9ad](650a9ad))
* download pdf in attachment folder and expose a variable {{{pdfAttachment}}} in the template ([bed8835](bed8835))
* expose positionPercent and positionAnchorIndex variables in highlight template ([omnivore-app#150](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/150)) ([fa3bd32](fa3bd32))
* highlight highlights in the exported content in markdown ([6cc1b04](6cc1b04))
* Now I can delete article from omnivore!!! ([3715beb](3715beb))
* render highlight color in article note ([c8a4e70](c8a4e70))
* start to sync when plugin is loaded ([omnivore-app#170](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/170)) ([280f027](280f027))
* use id as filename ([omnivore-app#154](https://github.com/someskumar-k/obsidian-omnivore-educative/issues/154)) ([74e255a](74e255a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Format dateArchived
2 participants