Skip to content

Commit ebe7096

Browse files
committed
Add recent posts section
1 parent ac2f087 commit ebe7096

File tree

5 files changed

+78
-1
lines changed

5 files changed

+78
-1
lines changed

content/contents.lr

+2
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,5 @@ links_plugins:
7070
<h5 class="link-heading"><a href="https://opensource.creativecommons.org/ccsearch-browser-extension/" class="has-text-forest-green">CC Search Browser Extension</a></h5>
7171
<p class="link-caption">Search the Catalog using our Extension.</p>
7272
</div>
73+
#### recent-posts ####
74+
title: Recent Blog Post

flowblocks/recent-posts.ini

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[block]
2+
name = Recent Posts
3+
4+
[fields.title]
5+
label = Title
6+
type = string

models/home.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ type = string
99
[fields.block_content]
1010
label = Block Content
1111
type = flow
12-
flow_blocks = hero, get-involved
12+
flow_blocks = hero, get-involved, recent-posts
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{% from "macros/author_name.html" import render_author_name %}
2+
3+
<section class="recent-posts">
4+
<div class="container">
5+
<div class="level">
6+
<h4 class="is-paddingless level-left">
7+
{{ this.title }}
8+
</h4>
9+
<span class="level-right">
10+
<a class="post-links" href="/blog">See all posts <i class="icon angle-right"></i></a>
11+
</span>
12+
</div>
13+
<div class="columns">
14+
{% for post in site.query('/blog/entries') %}
15+
{% if loop.index <= 3 %}
16+
{% set author = post.parent.parent.children.get('authors').children.get(post.author) %}
17+
<article class="card entry-post horizontal no-border blog-entry column is-one-third">
18+
<header>
19+
<figure class="image blog-image">
20+
{% if author.about %}
21+
{% if author.md5_hashed_email %}
22+
<img class="profile" src="https://secure.gravatar.com/avatar/{{ author.md5_hashed_email }}?size=200"
23+
alt="gravatar" />
24+
{% endif %}
25+
{% endif %}
26+
</figure>
27+
</header>
28+
<div class="blog-content">
29+
<h4 class="b-header"><a class="blog-title" href="{{ post|url }}">{{ post.title }}</a></h4>
30+
<span class="blog-author">by <a class="author-name" href="{{ author|url }}">{{ render_author_name(author) }}</a>
31+
on {{ post.pub_date|dateformat("YYYY-MM-dd") }}</span>
32+
<div class="excerpt">
33+
{{ post.body | excerpt | string | striptags() | truncate(100) }}
34+
</div>
35+
</div>
36+
</article>
37+
{% endif %}
38+
{% endfor %}
39+
</div>
40+
</div>
41+
</section>

webpack/sass/main.scss

+28
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,34 @@ a {
9090
}
9191
}
9292

93+
.recent-posts {
94+
background-color: rgba(4, 166, 53, 0.1);
95+
96+
.container {
97+
@extend .padding-vertical-xl;
98+
@extend .padding-horizontal-big;
99+
100+
.columns {
101+
@extend .padding-top-larger;
102+
@extend .padding-bottom-xl;
103+
}
104+
}
105+
106+
.post-links {
107+
@extend .has-color-forest-green;
108+
@extend .body-normal;
109+
110+
font-weight: bold;
111+
line-height: 1.5;
112+
text-decoration: none;
113+
114+
.icon {
115+
@extend .has-color-forest-green;
116+
@extend .padding-left-small;
117+
}
118+
}
119+
}
120+
93121
.breadcrumb-container {
94122
border-top: 4px solid $color-forest-green;
95123
background-color: $color-lighter-gray;

0 commit comments

Comments
 (0)