-
-
Notifications
You must be signed in to change notification settings - Fork 504
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
Null date throws an error #786
Comments
Looks like your fix works and it definitely feels clear. There's a check around line 625 for validity:
Which makes me feel like checking other types of validity is within the scope of the But let's say we wanted to avoid a change. Does it break convention to have front matter fields that are empty? What happens if you change it to:
Instead of just entirely blank? Is it more conventional to explicitly state that you have left this date blank? Or again, is it better to take the date field out if it's unused? I don't really have any answers or opinions for these questions, but maybe just some prompts to get discussion going about how Eleventy should handle this case in general. In the short term, would it fit into your workflow to remove the empty frontmatter for now and avoid the errors? |
Yeah those are good questions. The blank file template I'm using came stock with... octopress, I think? And they have a bunch of empty frontmatter fields that Jekyll silently ignores, so I always just left them alone. It does seem a bit odd to have blank fields though, and maybe it'd be clearer (for my own posts) if I left off the I can work around it by removing the empty field for now. |
I mean, I support adding |
Did a little thinking and a little reading, and I think you should submit your PR and see what @zachleat thinks. YAML treats empty nodes as But the I have a feeling Jekyll doesn't do anything with |
I had a similar issue with null tags - which I raised in this issue. Likewise I have a template markdown file with mostly blank keys - date always throws an error first time. If date isn't required by eleventy, I would support empty keys being ignored (like tags was above). |
Yep I’m on board with this—take care not to change any existing unit tests in your pull request please! I want to know if anything fails |
fix 11ty#786 Co-Authored-By: Dave Ceddia <[email protected]>
Describe the bug
I'm converting an existing Jekyll blog to Eleventy. I have some pages that have an empty
date
in the frontmatter, and Eleventy is crashing with the errorCannot read property 'toLowerCase' of null
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
I expected the empty date to be ignored. For some posts or pages the date isn't relevant and I don't want to show it on the page at all. Maybe there's a better way to do this?
Environment:
Additional context
Near where it fails, in
Template.js
, I can fix the crash by changing this line:to this:
Should I create a PR? Is there a better way to fix it?
The text was updated successfully, but these errors were encountered: