diff --git a/_plugins/itemizer.rb b/_plugins/itemizer.rb new file mode 100644 index 000000000..fb661a855 --- /dev/null +++ b/_plugins/itemizer.rb @@ -0,0 +1,35 @@ +# Jekyll plugin to itemize each post for JSON output +# Parses the current pattern of every item beginning with +#

/ ... + +require 'jekyll' +require 'json' + + +module Jekyll + 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(/

\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 + + end +end +Liquid::Template.register_filter(Jekyll::Itemizer) \ No newline at end of file diff --git a/api/today.json b/api/today.json new file mode 100644 index 000000000..005c1cb24 --- /dev/null +++ b/api/today.json @@ -0,0 +1,5 @@ +--- +layout: null +--- + +{{ site.posts[0] | itemize }} \ No newline at end of file