Created
May 30, 2016 12:48
-
-
Save kremalicious/025bb40d49d51ca2cfa169f956820967 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # http://stackoverflow.com/a/27850727/733677 | |
| require 'open-uri' | |
| require 'rss' | |
| module Jekyll | |
| # Runs during jekyll build | |
| class RssFeedCollector < Generator | |
| safe true | |
| priority :high | |
| def generate(site) | |
| rss_items = RSS::Parser.parse(open('https://blog.chartmogul.com/feed/').read, false) | |
| # Create a new on-the-fly Jekyll collection called "external_feed" | |
| jekyll_items = Jekyll::Collection.new(site, 'external_feed') | |
| site.collections['external_feed'] = jekyll_items | |
| # Add fake virtual documents to the collection | |
| rss_items.items.each do |item| | |
| title = item.title | |
| #content = item.description | |
| guid = item.guid | |
| path = "_rss/" + title + ".md" | |
| path = site.in_source_dir(path) | |
| doc = Jekyll::Document.new(path, { :site => site, :collection => jekyll_items }) | |
| doc.data['title'] = title; | |
| #doc.data['feed_content'] = content; | |
| jekyll_items.docs << doc | |
| end | |
| end | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {% for item in site.collections['external_feed'].docs %} | |
| <h2>{{ item.title }}</h2> | |
| {% endfor %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment