eleventyConfig.addDateParsing, am I missing something? #3642
Replies: 1 comment
-
Ah nevermind, I figured out why it wasn't grabbing the formatted date. Documentation says Eleventy will never perform transformations on |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hey there,
Looks like custom date parsing is a relatively new feature to version 3 so I haven't really seen it discussed or implemented. It looks super useful though if it works the way I think it does.
My previous implementation to go about this involved using 2 filters which worked fine (and worst case, I will just keep using them). If it works, I believe I can remove 1 filter and let the config handle that parsing instead.
So what I have happening is a series of posts (markdown files) front mattering
date
. Example:'13-04-2020'
.When I read the documentation on custom date parsing, it seems like to me when done right, Eleventy will grab this date value and parse it for you technically updating that date's value for templates to use. Correct me if I am wrong here.
My end goal is to simply produce an ISO 8601 string and return that for templates to use using Luxon. Here's the process so far:
eleventy.config.js
Here Eleventy gives an error "fromFormat requires an input string and a format". The logs tell me that Eleventy is expecting ALL of my markdown files to have a date value to parse. In addition to the date values it successfully grabbed from my posts, it's also trying to parse
undefined
from markdown files that don't use a date value which comes up 16 times. Ah well, I can check for that as a "fix":Awesome, Eleventy now parses my example date correctly from
'13-04-2020'
to'2020-04-13T00:00:00.000Z'
after doing a check first.Despite this, my template still uses
'13-04-2020'
when I input{{ date }}
on my template. Shouldn't it be updated to the new ISO Date string? Unsure if this might be a data cascade thing because I don't think this counts as global config data. Any ideas?Beta Was this translation helpful? Give feedback.
All reactions