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

Issues with 'Error: date front matter value' when date seems valid? #2635

Closed
wholewheattoast opened this issue Oct 31, 2022 · 4 comments
Closed

Comments

@wholewheattoast
Copy link

Describe the bug
I'm in the process of converting a Jekyll site over to Eleventy. When building I'm getting a ton of 'Error: date front matter value' errors for what appear to be valid datetimes in my front matter.

To Reproduce
Steps to reproduce the behavior:

  1. run npx @11ty/eleventy
  2. see error
~/s/wwt-eleventy (main|…) $ npx @11ty/eleventy
[11ty] Problem writing Eleventy templates: (more in DEBUG output)
[11ty] date front matter value (2015-01-03 22:54:43 GMT) is invalid for ./posts/2015-01-03-how-much-did-you-pay.html (via Error)
[11ty] 
[11ty] Original error stack trace: Error: date front matter value (2015-01-03 22:54:43 GMT) is invalid for ./posts/2015-01-03-how-much-did-you-pay.html
[11ty]     at Template.getMappedDate (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/Template.js:1043:15)
[11ty]     at Template.addPageDate (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/Template.js:453:30)
[11ty]     at Template.getData (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/Template.js:434:31)
[11ty]     at async Template.getTemplateMapEntries (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/Template.js:1087:33)
[11ty]     at async TemplateMap.add (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/TemplateMap.js:59:21)
[11ty]     at async Promise.all (index 1081)
[11ty]     at async TemplateWriter._createTemplateMap (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/TemplateWriter.js:243:5)
[11ty]     at async TemplateWriter.generateTemplates (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/TemplateWriter.js:277:5)
[11ty]     at async TemplateWriter.write (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/TemplateWriter.js:323:23)
[11ty]     at async Eleventy.executeBuild (/Users/shawn/source/wwt-eleventy/node_modules/@11ty/eleventy/src/Eleventy.js:1003:13)
[11ty] Wrote 0 files in 0.86 seconds (v1.0.2)

YAML front matter:

---
layout: post
title: how much did you pay
date: 2015-01-03 22:54:43 GMT
tags: []
tumblr_url: http://wholewheattoast.tumblr.com/post/107046836634/how-much-did-you-pay
source_url: http://instagram.com/p/xaMfKShnK7/
tumblr_img_permalink: 
---

Expected behavior**
Expected the page to build.

Screenshots
YAMLLint seems to think it's valid?
Screen Shot 2022-10-30 at 10 56 54 PM

Environment:

  • OS and Version: [e.g. Windows/Mac/Linux] MacOS 12.1
  • Eleventy Version [via eleventy --version or npx @11ty/eleventy --version] 1.0.2

Additional context
Example from another YAML parser

@pdehaan
Copy link
Contributor

pdehaan commented Oct 31, 2022

Interesting... The YAMLLint value is quoted, the front matter version isn't.
I'd guess it's choking on the : time separator.
But even w/ quoted date it seems to be giving me an error w/ your string.

Per https://www.11ty.dev/docs/dates/ I think it needs to be a full ISO date that Luxon can parse, like "2015-01-03T22:54:43"

@pdehaan
Copy link
Contributor

pdehaan commented Oct 31, 2022

https://npm.runkit.com/luxon

const { DateTime}  = require("luxon")
const res = DateTime.fromISO("2015-01-03 22:54:43 GMT");
console.log({res});

"invalid: Invalid {reason: "unparsable", explanation: "the input \"2015-01-03 22:54:43 GMT\" can't be parsed as ISO 8601"}"

@wholewheattoast
Copy link
Author

Thank you for the details.

I'd point out that the yaml provided to YAMLLint wasn't quoted, it only returned it that way.
The page does say that,
"
Paste in your YAML and click "Go" - we'll tell you if it's valid or not, and give you a nice clean UTF-8 version of it. Optimized for Ruby.
"

@zachleat
Copy link
Member

zachleat commented Dec 6, 2022

https://nodeca.github.io/js-yaml/ is what Eleventy uses under the hood!

@pdehaan is right. The date is not a valid YAML date. https://yaml.org/type/timestamp.html

Eleventy does have a fallback for these cases, but it isn’t a valid ISO 8601 either 😅 https://moment.github.io/luxon/#/parsing?id=iso-8601

Content dates docs on 11ty: https://www.11ty.dev/docs/dates/

I think your best bet forward here is to upvote and lobby for #867

Thanks!

@zachleat zachleat closed this as completed Dec 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants