Skip to content

Commit

Permalink
write some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithmilo committed Jun 1, 2017
1 parent d59d723 commit a208580
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion _plugins/itemizer.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Jekyll plugin to itemize each post for JSON output
# Parses the current pattern of every item beginning with
# <p><Number>/ ...

require 'jekyll'
require 'json'

Expand All @@ -10,16 +11,22 @@ module Itemizer

def itemize(post)


# splits the contents into items for each story. Slice off
# the first one, since it's an empty string
item_list = post.content.split(/<p>\d\//).slice(1..-1)

# make the list into an indexed array
items = Hash[(1...item_list.size).zip item_list]

# setup the entire output with any other desired keys
output = ({
:title => post['title'],
:description => post['description'],
:date => post['date'],
:items => items
})

# ship it!
output.to_json
end

Expand Down

0 comments on commit a208580

Please sign in to comment.