1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-12-24 02:16:10 +01:00

proof of concept for getting latests posts from Medium

This commit is contained in:
Matthias Kretschmann 2017-05-23 18:43:12 +02:00
parent ee016e101d
commit e71b01d51b
Signed by: m
GPG Key ID: BD3C1F3EDD7831FC
7 changed files with 83 additions and 0 deletions

View File

@ -9,4 +9,5 @@ end
group :jekyll_plugins do
gem 'hash-joiner'
gem 'simple-rss'
end

View File

@ -90,3 +90,4 @@
@import '_sections/section-cta-community';
@import '_sections/section-cta-enterprise';
@import '_sections/section-partners';
@import '_sections/section-blog';

View File

@ -0,0 +1,11 @@
.section--blog {
}
.article {
}
.article__title {
@extend .h6;
}

View File

@ -16,6 +16,10 @@
p {
color: $brand-main-gray;
}
h1, h2, h3, h4 {
color: $brand-main-blue;
}
}
.background--gray {

View File

@ -0,0 +1,24 @@
<section class="section section--blog background--light">
<div class="row row--wide">
<header class="section-header">
<h1 class="section-title">Hot off the blog</h1>
</header>
<div class="grid grid--full grid-medium--fit grid--gutters">
{% for article in site.blog | limit: 3 %}
<div class="grid__col">
<a class="article article--{{ article.title | downcase | truncatewords: 3, '' | replace: ' ', '-' }}" href="{{ article.link }}">
<!-- <img src="{{ article.image }}" alt="{{ article.title }}"> -->
<h1 class="article__title">
{{ article.title }}
</h1>
<p>{{ article.description }}</p>
</a>
</div>
{% endfor %}
</div>
</div>
</section>

40
_src/_plugins/blog.rb Normal file
View File

@ -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

View File

@ -59,4 +59,6 @@ redirect_from:
{% include sections/section-cta-features.html %}
{% include sections/section-blog.html %}
{% include ipdb.html %}