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

Allow quoted date in front matter defaults #4184

Merged
merged 3 commits into from Dec 11, 2015

Conversation

@ducktyper
Copy link
Contributor

@ducktyper ducktyper commented Nov 25, 2015

Fix to #4068

envygeeks
Copy link
Contributor

envygeeks commented on e60e5f3 Dec 28, 2015

I just noticed this when the suite started failing, this is a bad test.

@envygeeks
Copy link
Contributor

@envygeeks envygeeks commented Nov 25, 2015

❤️ for doing this @ducktyper

@ducktyper
Copy link
Contributor Author

@ducktyper ducktyper commented Nov 25, 2015

Yes! that is the better name. Thanks for the quick feedback.

@parkr
Copy link
Member

@parkr parkr commented Nov 25, 2015

This seems like a lack of flexibility on the users' parts. What if a user wants a string there and now we force a date? YAML parses dates just fine: just don't quote it.

@envygeeks
Copy link
Contributor

@envygeeks envygeeks commented Nov 28, 2015

Personally if this were my site I would expect anything labled "date" to be turned into an Object and enforced as so, and if I want a string I would not use an internal front-matter variable that is expected to be a date.

@ducktyper
Copy link
Contributor Author

@ducktyper ducktyper commented Dec 1, 2015

If I understand the code correctly, in my opinion, I believe the value of "date" from default front-matter and front-matter (of each post or collection file) need to be handled in the same way, because they both can be the value of data["date"] in a Document object which is used as a Time object.

Since Jekyll converts the value of "date" in front-matter to a Time object already in the same way, it is logical to do the same to the default front-matter unless that is not the desirable behaviour.

def ensure_time!(set)
return set unless set.key?('values') && set['values'].key?('date')
return set if set['values']['date'].is_a?(Time)
set['values']['date'] = Utils.parse_date(set['values']['date'], "Front matter defaults does not have a valid date.")
Copy link
Member

@parkr parkr Dec 4, 2015

Can you indicate something more helpful in this error message? If you have a 200-line config.yml, this is going to be an annoying error.

@ducktyper
Copy link
Contributor Author

@ducktyper ducktyper commented Dec 5, 2015

Now the error message shows which front-matter default set to look for by showing the set.
Also found a grammar mistake. Sorry for my unprofessional writing skill.
The invalid date is shown from Utils.parse_date method so I did not need to re-display it.

Here is an example error message that could be generated.

         ERROR: YOUR SITE COULD NOT BE BUILT:
                ------------------------------------
                Invalid date '2000-01-0': An invalid date format was found in a front-matter default set: {"scope"=>{"path"=>""}, "values"=>{"layout"=>"post", "date"=>"2000-01-0"}}

Let me know if I missed something else or need more explanation.
Thanks for your feedback.

parkr added a commit that referenced this issue Dec 11, 2015
@parkr parkr merged commit 4f21458 into jekyll:master Dec 11, 2015
1 check passed
parkr added a commit that referenced this issue Dec 11, 2015
envygeeks
Copy link
Contributor

envygeeks commented on e60e5f3 Dec 28, 2015

I just noticed this when the suite started failing, this is a bad test.

@ducktyper
Copy link
Contributor Author

@ducktyper ducktyper commented Dec 28, 2015

I want to fix the bad test but could you enlighten me with little more detail?
I reviewed the tests and came with some ideas but I'm guessing I missed something else.

  1. Using .any? is more readable than .find with "assert" method because .any? returns true/false while .find returns page/nil
  2. Tests "not raise error" and "parse date" can be merged to reduce testing time since @site.process method takes some time to run.

@jekyll jekyll locked and limited conversation to collaborators Feb 27, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants