diff --git a/lib/jekyll-compose/file_info.rb b/lib/jekyll-compose/file_info.rb index 44a08e0..a0d941c 100644 --- a/lib/jekyll-compose/file_info.rb +++ b/lib/jekyll-compose/file_info.rb @@ -10,21 +10,11 @@ def file_name end def content - <<-CONTENT.gsub /^\s+/, '' - --- - layout: #{params.layout} - title: #{yaml_clean_title} - --- - CONTENT - end - - private + front_matter = YAML.dump({ + 'layout' => params.layout, + 'title' => params.title, + }) - def yaml_clean_title - if params.title.include? ':' - '"' + params.title + '"' - else - params.title - end + front_matter + "---\n" end end diff --git a/spec/file_info_spec.rb b/spec/file_info_spec.rb index 5945a92..8851ea0 100644 --- a/spec/file_info_spec.rb +++ b/spec/file_info_spec.rb @@ -25,7 +25,7 @@ let(:expected_result) {<<-CONTENT.gsub(/^\s+/, '') --- layout: post - title: "A test: arg parser" + title: 'A test: arg parser' --- CONTENT }