From e71b01d51b68bf86fdc3eb7d8017c013b00e6e6e Mon Sep 17 00:00:00 2001 From: Matthias Kretschmann Date: Tue, 23 May 2017 18:43:12 +0200 Subject: [PATCH] proof of concept for getting latests posts from Medium --- Gemfile | 1 + _src/_assets/styles/_sections.scss | 1 + .../styles/_sections/_section-blog.scss | 11 +++++ .../styles/bigchain/_mixins/_backgrounds.scss | 4 ++ _src/_includes/sections/section-blog.html | 24 +++++++++++ _src/_plugins/blog.rb | 40 +++++++++++++++++++ _src/index.html | 2 + 7 files changed, 83 insertions(+) create mode 100644 _src/_assets/styles/_sections/_section-blog.scss create mode 100644 _src/_includes/sections/section-blog.html create mode 100644 _src/_plugins/blog.rb diff --git a/Gemfile b/Gemfile index 200cb82..30bbd06 100644 --- a/Gemfile +++ b/Gemfile @@ -9,4 +9,5 @@ end group :jekyll_plugins do gem 'hash-joiner' + gem 'simple-rss' end diff --git a/_src/_assets/styles/_sections.scss b/_src/_assets/styles/_sections.scss index 2303ed6..f5444c0 100644 --- a/_src/_assets/styles/_sections.scss +++ b/_src/_assets/styles/_sections.scss @@ -90,3 +90,4 @@ @import '_sections/section-cta-community'; @import '_sections/section-cta-enterprise'; @import '_sections/section-partners'; +@import '_sections/section-blog'; diff --git a/_src/_assets/styles/_sections/_section-blog.scss b/_src/_assets/styles/_sections/_section-blog.scss new file mode 100644 index 0000000..0ef37f9 --- /dev/null +++ b/_src/_assets/styles/_sections/_section-blog.scss @@ -0,0 +1,11 @@ +.section--blog { + +} + +.article { + +} + +.article__title { + @extend .h6; +} diff --git a/_src/_assets/styles/bigchain/_mixins/_backgrounds.scss b/_src/_assets/styles/bigchain/_mixins/_backgrounds.scss index 600ecea..eb461b0 100644 --- a/_src/_assets/styles/bigchain/_mixins/_backgrounds.scss +++ b/_src/_assets/styles/bigchain/_mixins/_backgrounds.scss @@ -16,6 +16,10 @@ p { color: $brand-main-gray; } + + h1, h2, h3, h4 { + color: $brand-main-blue; + } } .background--gray { diff --git a/_src/_includes/sections/section-blog.html b/_src/_includes/sections/section-blog.html new file mode 100644 index 0000000..31c5f7a --- /dev/null +++ b/_src/_includes/sections/section-blog.html @@ -0,0 +1,24 @@ +
+
+
+

Hot off the blog

+
+ +
+ {% for article in site.blog | limit: 3 %} + + {% endfor %} +
+ +
+
diff --git a/_src/_plugins/blog.rb b/_src/_plugins/blog.rb new file mode 100644 index 0000000..6605790 --- /dev/null +++ b/_src/_plugins/blog.rb @@ -0,0 +1,40 @@ +# http://stackoverflow.com/a/27850727/733677 + +require 'open-uri' +require 'rss' +require 'simple-rss' + +module Jekyll + + # Runs during jekyll build + class RssFeedCollector < Generator + safe true + priority :high + def generate(site) + + rss_items = SimpleRSS.parse open('https://blog.bigchaindb.com/feed/') + + # Create a new on-the-fly Jekyll collection called "blog" + jekyll_items = Jekyll::Collection.new(site, 'blog') + site.collections['blog'] = jekyll_items + + # Add fake virtual documents to the collection + rss_items.items.each do |item| + title = item.title + description = item.description + link = item.link + image = item.media_content_url + path = "_rss/" + title.to_s.gsub(':','_') + ".md" + path = site.in_source_dir(path) + doc = Jekyll::Document.new(path, site: site, collection: jekyll_items) + doc.data['title'] = title + doc.data['description'] = description + doc.data['link'] = link + doc.data['image'] = image + jekyll_items.docs << doc + end + + end + end + +end diff --git a/_src/index.html b/_src/index.html index 6dc72a0..478a863 100644 --- a/_src/index.html +++ b/_src/index.html @@ -59,4 +59,6 @@ redirect_from: {% include sections/section-cta-features.html %} +{% include sections/section-blog.html %} + {% include ipdb.html %}