Skip to content

Commit

Permalink
resolves #149 merge category into categories; tag into tags (#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
mojavelinux authored May 21, 2017
1 parent 9750105 commit 2d9331e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/jekyll-asciidoc/integrator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ def integrate document, collection_name = nil
data.update adoc_data
end

{ 'category' => 'categories', 'tag' => 'tags' }.each do |sole_key, coll_key|
if (sole_val = data.delete sole_key) &&
!((coll_val = (data[coll_key] ||= [])).include? sole_val)
coll_val << sole_val
end
end

case data['layout']
when nil
document.content = %(#{StandaloneOptionLine}#{document.content}) unless data.key? 'layout'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
= Post With Categories
:page-category: node
:page-categories: [code, javascript]
:page-tag: tip
:page-tags: [syntax, beginner]

Lorem ipsum.
11 changes: 11 additions & 0 deletions spec/jekyll-asciidoc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,17 @@
end
end

it 'should merge singular variables with collection variables' do
post = find_post '2016-02-02-post-with-singular-vars.adoc'
expect(post).not_to be_nil
expect(post.data['categories']).to eql(['code', 'javascript', 'node'])
expect(post.data['tags']).to eql(['syntax', 'beginner', 'tip'])
if ::Jekyll::MIN_VERSION_3
file = output_file 'code/javascript/node/2016/02/02/post-with-singular-vars.html'
expect(::File).to exist(file)
end
end

it 'should convert revdate to local Time object and use it as date of post' do
# NOTE Time.parse without time zone assumes time zone of site
date = ::Time.parse('2016-06-15 10:30:00')
Expand Down

0 comments on commit 2d9331e

Please sign in to comment.