Skip to content

Commit 1e128a1

Browse files
committed
Merge pull request #9 from jekyll/platanus-markdown_md_default
2 parents 0251394 + 00ec9b4 commit 1e128a1

File tree

5 files changed

+13
-11
lines changed

5 files changed

+13
-11
lines changed

lib/jekyll-compose.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
module Jekyll
44
module Compose
5+
DEFAULT_TYPE = "md"
6+
DEFAULT_LAYOUT = "post"
57
end
68
end
79

lib/jekyll/commands/draft.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ def self.init_with_program(prog)
1919
def self.process(args = [], options = {})
2020
raise ArgumentError.new('You must specify a name.') if args.empty?
2121

22-
type = options["type"] || "markdown"
23-
layout = options["layout"] || "post"
22+
type = options["type"] || Jekyll::Compose::DEFAULT_TYPE
23+
layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT
2424

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

lib/jekyll/commands/post.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def self.init_with_program(prog)
2020
def self.process(args = [], options = {})
2121
raise ArgumentError.new('You must specify a name.') if args.empty?
2222

23-
type = options["type"].nil? ? "markdown" : options["type"]
24-
layout = options["layout"].nil? ? "post" : options["layout"]
23+
type = options["type"] || Jekyll::Compose::DEFAULT_TYPE
24+
layout = options["layout"] || Jekyll::Compose::DEFAULT_LAYOUT
2525

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

spec/draft_spec.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let(:name) { 'A test post' }
33
let(:args) { [name] }
44
let(:drafts_dir) { Pathname.new source_dir('_drafts') }
5-
let(:path) { drafts_dir.join('a-test-post.markdown') }
5+
let(:path) { drafts_dir.join('a-test-post.md') }
66

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

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

3131
it 'errors with no arguments' do
@@ -36,7 +36,7 @@
3636

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

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

5151
it 'overwrites if --force is given' do

spec/post_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let(:name) { 'A test post' }
33
let(:args) { [name] }
44
let(:posts_dir) { Pathname.new source_dir('_posts') }
5-
let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-a-test-post.markdown" }
5+
let(:filename) { "#{Time.now.strftime('%Y-%m-%d')}-a-test-post.md" }
66
let(:path) { posts_dir.join(filename) }
77

88
before(:all) do
@@ -37,7 +37,7 @@
3737

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

4242
before(:each) do
4343
FileUtils.touch path

0 commit comments

Comments
 (0)