mirror of
https://github.com/bigchaindb/site.git
synced 2025-02-14 21:10:28 +01:00
Merge pull request #126 from ascribe/feature/blogposts
Blog posts section
This commit is contained in:
commit
ba91f5a5f0
1
Gemfile
1
Gemfile
@ -9,4 +9,5 @@ end
|
||||
|
||||
group :jekyll_plugins do
|
||||
gem 'hash-joiner'
|
||||
gem 'simple-rss'
|
||||
end
|
||||
|
@ -90,3 +90,4 @@
|
||||
@import '_sections/section-cta-community';
|
||||
@import '_sections/section-cta-enterprise';
|
||||
@import '_sections/section-partners';
|
||||
@import '_sections/section-blog';
|
||||
|
33
_src/_assets/styles/_sections/_section-blog.scss
Normal file
33
_src/_assets/styles/_sections/_section-blog.scss
Normal file
@ -0,0 +1,33 @@
|
||||
.section--blog {
|
||||
|
||||
}
|
||||
|
||||
.article {
|
||||
@include color-overlay;
|
||||
@include transition;
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
padding: $spacer;
|
||||
border-radius: $border-radius;
|
||||
overflow: hidden;
|
||||
box-shadow: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 7rem;
|
||||
|
||||
&:hover,
|
||||
&:focus {
|
||||
background-size: cover;
|
||||
background-position: center;
|
||||
box-shadow: 0 2px 5px rgba($brand-main-blue-dark, .2);
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
}
|
||||
|
||||
.article__title {
|
||||
@extend .h6, .transition;
|
||||
margin: 0;
|
||||
color: #fff;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
@ -60,7 +60,7 @@ $line-height: 1.5 !default;
|
||||
|
||||
$headings-font-family: inherit !default;
|
||||
$headings-font-weight: $font-weight-light !default;
|
||||
$headings-line-height: 1.2 !default;
|
||||
$headings-line-height: 1.3 !default;
|
||||
$headings-color: $brand-main-blue-light !default;
|
||||
|
||||
|
||||
|
22
_src/_includes/sections/section-blog.html
Normal file
22
_src/_includes/sections/section-blog.html
Normal file
@ -0,0 +1,22 @@
|
||||
<section class="section section--blog ">
|
||||
<div class="row row--wide">
|
||||
|
||||
<div class="grid grid--full grid-small--half grid-medium--third grid--gutters">
|
||||
{% for article in site.articles | limit: 6 %}
|
||||
<div class="grid__col">
|
||||
<a class="article article--{{ article.title | downcase | truncatewords: 3, '' | replace: ' ', '-' }}" href="{{ article.link }}" style="background-image: url('{{ article.image }}')">
|
||||
|
||||
<h1 class="article__title">
|
||||
{{ article.title }}
|
||||
</h1>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
<p class="text-center">
|
||||
<a class="btn btn-secondary" href="{{ site.blog }}">Go to blog</a>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</section>
|
41
_src/_plugins/blog.rb
Normal file
41
_src/_plugins/blog.rb
Normal file
@ -0,0 +1,41 @@
|
||||
# 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 "articles"
|
||||
jekyll_items = Jekyll::Collection.new(site, 'articles')
|
||||
site.collections['articles'] = jekyll_items
|
||||
|
||||
# Add fake virtual documents to the collection
|
||||
rss_items.items.each do |item|
|
||||
title = item.title
|
||||
link = item.link
|
||||
|
||||
# Medium hack: get first image in content, then get smaller image size
|
||||
image = item.content_encoded[/img.*?src="(.*?)"/i,1].gsub(/max\/(.*)\//, "max/500/")
|
||||
|
||||
path = '_articles/' + 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['link'] = link
|
||||
doc.data['image'] = image
|
||||
jekyll_items.docs << doc
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -59,4 +59,6 @@ redirect_from:
|
||||
|
||||
{% include sections/section-cta-features.html %}
|
||||
|
||||
{% include sections/section-blog.html %}
|
||||
|
||||
{% include ipdb.html %}
|
||||
|
Loading…
Reference in New Issue
Block a user