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 additional front matter for Post #41

Merged
merged 7 commits into from Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions lib/jekyll/commands/post.rb
Expand Up @@ -64,8 +64,17 @@ def _time_stamp
end

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

private

def compose_config
@compose_config ||= Jekyll.configuration["jekyll_compose"] || {}
end
end
end
end
Expand Down
12 changes: 11 additions & 1 deletion spec/post_spec.rb
Expand Up @@ -113,15 +113,25 @@
expect(path).to exist
end

context "auto_open editor is set" do
context "configuration is set" do
let(:posts_dir) { Pathname.new source_dir("_posts") }
let(:config_data) do
%(
jekyll_compose:
auto_open: true
post_default_front_matter:
description: my description
category:
)
end

it "creates post with the specified config" do
capture_stdout { described_class.process(args) }
post = File.read(path)
expect(post).to match(%r!description: my description!)
expect(post).to match(%r!category: !)
end

context "env variable EDITOR is set up" do
before { ENV["EDITOR"] = "vim" }

Expand Down