-
Notifications
You must be signed in to change notification settings - Fork 80
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 additional front matter for Post #41
Conversation
Thanks a lot @toshimaru . In fact, I'm writing a short blog introducing |
I'd LOVE to see this feature merged in. |
able to add draft and post front matter in _config.yml in Jekyll directory. adopted from toshimaru's PR (jekyll#41)
@codethebeard Totally, I installed this package and immediately though of this feature! |
+1 to this feature. This project is not particularly useful without it for me. |
There was some online interface I saw once that allowed default YAML for posts to be stored in a way similar to this. Does that ring a bell for anybody? If somebody out there is already doing this, we should make sure that the way we do it is complementary to that. |
@pathawks rather than adding extra options, I think |
I’m not sure about this. Seems best to leave it to the authors to add only what is needed. I would argue that maybe we should stop adding |
Almost all of my posts have different
Might be a good idea, but I'd like to configure post default setting separately because it has a value for the layout, not for the post. |
LGTM please!!! I hope this is also added to the I'm really surprised that this capability was left out because, as others have pointed out, it's expected or very, very high on the want list. It's the main reason why I bothered to search for this plugin. I agree with @toshimaru original approach - have a full list of common defaults, prefilled where applicable with sensible values, and allow user to configure in the _config.yml file. To me, this is equivalent to |
lib/jekyll/commands/post.rb
Outdated
@@ -53,6 +53,11 @@ def file_name | |||
def _date_stamp | |||
@params.date.strftime '%Y-%m-%d' | |||
end | |||
|
|||
def content | |||
post_front_matter = Jekyll.configuration["post_front_matter"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use a different configuration key here. I'd love to keep things organized under compose
. What about:
compose:
post_default_front_matter:
my: keys
go: here
Top-level keys often conflict with user-specific values and it's nice to keep a plugin's keys all under one namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jekyll_compose
is used as a top-level namespace, so I use the same naming.
005b2af
to
8195ded
Compare
fe54470
to
557eb97
Compare
557eb97
to
a653e4a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, as jekyll_compose
is already used as configuration key by auto_open
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@toshimaru This would benefit from some minor changes..
lib/jekyll/commands/post.rb
Outdated
private | ||
|
||
def jekyll_compose_config | ||
@jekyll_compose_config ||= Jekyll.configuration["jekyll_compose"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's default the config to a hash so that we can avoid a nil
check in method #content
above:
# Returns a Hash
def compose_config
@compose_config ||= Jekyll.configuration["jekyll_compose"] || {}
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been adressed in #76
lib/jekyll/commands/post.rb
Outdated
@@ -64,8 +64,18 @@ def _time_stamp | |||
end | |||
|
|||
def content(custom_front_matter = {}) | |||
if jekyll_compose_config && jekyll_compose_config["post_default_front_matter"] | |||
custom_front_matter.merge!(jekyll_compose_config["post_default_front_matter"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's merge!
only a valid config:
def content(custom_front_matter = {})
default_front_matter = compose_config["post_default_front_matter"]
custom_front_matter.merge!(default_front_matter) if default_front_matter.is_a?(Hash)
super({ "date" => _time_stamp }.merge(custom_front_matter))
end
@ashmaroli thanks for your review, fixed!! |
@toshimaru Thank you for addressing my concerns. You may refer #76 for more details regarding the proposed change |
@ashmaroli So, should I wait until #76 get merged? |
@toshimaru We'll deal with @jekyllbot: merge +minor |
Note: this does not currently work for drafts. |
Currently, jekyll-compose
post
command generates onlylayout
andtitle
as front matter, but I'd like to add more front matters. For example:This PR adds feature that allows addtional front matter loaded from Jekyll's
_config.yml
forjekyll post
command._config.yml
sample is like: