Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/jekyll-compose.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

module Jekyll
module Compose
DEFAULT_TYPE = "md"
DEFAULT_LAYOUT = "post"
end
end

Expand Down
6 changes: 3 additions & 3 deletions lib/jekyll/commands/draft.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ def self.init_with_program(prog)
def self.process(args = [], options = {})
raise ArgumentError.new('You must specify a name.') if args.empty?

type = options["type"] || "markdown"
layout = options["layout"] || "post"
type = options["type"] || Jekyll::Compose::DEFAULT_TYPE
layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT

title = args.shift
name = title.gsub(' ', '-').downcase
Expand All @@ -38,7 +38,7 @@ def self.process(args = [], options = {})
# Internal: Gets the filename of the draft to be created
#
# Returns the filename of the draft, as a String
def self.draft_name(name, ext='markdown')
def self.draft_name(name, ext=Jekyll::Compose::DEFAULT_TYPE)
"_drafts/#{name}.#{ext}"
end

Expand Down
4 changes: 2 additions & 2 deletions lib/jekyll/commands/post.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ def self.init_with_program(prog)
def self.process(args = [], options = {})
raise ArgumentError.new('You must specify a name.') if args.empty?

type = options["type"].nil? ? "markdown" : options["type"]
layout = options["layout"].nil? ? "post" : options["layout"]
type = options["type"] || Jekyll::Compose::DEFAULT_TYPE
layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT

date = options["date"].nil? ? Time.now : DateTime.parse(options["date"])

Expand Down
8 changes: 4 additions & 4 deletions spec/draft_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let(:name) { 'A test post' }
let(:args) { [name] }
let(:drafts_dir) { Pathname.new source_dir('_drafts') }
let(:path) { drafts_dir.join('a-test-post.markdown') }
let(:path) { drafts_dir.join('a-test-post.md') }

before(:all) do
FileUtils.mkdir_p source_dir unless File.directory? source_dir
Expand All @@ -25,7 +25,7 @@

it 'writes a helpful success message' do
output = capture_stdout { described_class.process(args) }
expect(output).to eql("New draft created at ./_drafts/a-test-post.markdown.\n")
expect(output).to eql("New draft created at ./_drafts/a-test-post.md.\n")
end

it 'errors with no arguments' do
Expand All @@ -36,7 +36,7 @@

context 'when the draft already exists' do
let(:name) { 'An existing draft' }
let(:path) { drafts_dir.join('an-existing-draft.markdown') }
let(:path) { drafts_dir.join('an-existing-draft.md') }

before(:each) do
FileUtils.touch path
Expand All @@ -45,7 +45,7 @@
it 'raises an error' do
expect(-> {
capture_stdout { described_class.process(args) }
}).to raise_error("A draft already exists at ./_drafts/an-existing-draft.markdown")
}).to raise_error("A draft already exists at ./_drafts/an-existing-draft.md")
end

it 'overwrites if --force is given' do
Expand Down
4 changes: 2 additions & 2 deletions spec/post_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
let(:name) { 'A test post' }
let(:args) { [name] }
let(:posts_dir) { Pathname.new source_dir('_posts') }
let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-a-test-post.markdown" }
let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-a-test-post.md" }
let(:path) { posts_dir.join(filename) }

before(:all) do
Expand Down Expand Up @@ -37,7 +37,7 @@

context 'when the post already exists' do
let(:name) { 'An existing post' }
let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-an-existing-post.markdown" }
let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-an-existing-post.md" }

before(:each) do
FileUtils.touch path
Expand Down