Skip to content

Commit 60209cf

Browse files
authored
Implemented latest posts on about page (alshedivat#1307)
Adresses alshedivat#340 --------- Signed-off-by: George Araújo <george.gcac@gmail.com>
1 parent 5ff54a7 commit 60209cf

File tree

5 files changed

+57
-17
lines changed

5 files changed

+57
-17
lines changed

_config.yml

+9-2
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,15 @@ collections:
174174
output: true
175175
permalink: /projects/:path/
176176

177-
news_scrollable: true # adds a vertical scroll bar if there are more than 3 news items
178-
news_limit: 5 # leave blank to include all the news in the `_news` folder
177+
news:
178+
enabled: true
179+
scrollable: true # adds a vertical scroll bar if there are more than 3 news items
180+
limit: 5 # leave blank to include all the news in the `_news` folder
181+
182+
latest_posts:
183+
enabled: true
184+
scrollable: true # adds a vertical scroll bar if there are more than 3 new posts items
185+
limit: 3 # leave blank to include all the blog posts
179186

180187
# -----------------------------------------------------------------------------
181188
# Jekyll settings

_includes/latest_posts.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
<div class="news">
3+
{% if site.latest_posts != blank -%}
4+
{%- assign latest_posts_size = site.posts | size -%}
5+
<div class="table-responsive" {% if site.latest_posts.scrollable and latest_posts_size > 3 %}style="max-height: 10vw"{% endif %}>
6+
<table class="table table-sm table-borderless">
7+
{%- assign latest_posts = site.posts -%}
8+
{% if site.latest_posts.limit %}
9+
{% assign latest_posts_limit = site.latest_posts.limit %}
10+
{% else %}
11+
{% assign latest_posts_limit = latest_posts_size %}
12+
{% endif %}
13+
{% for item in latest_posts limit: latest_posts_limit %}
14+
<tr>
15+
<th scope="row">{{ item.date | date: "%b %-d, %Y" }}</th>
16+
<td>
17+
<a class="news-title" href="{{ item.url | relative_url }}">{{ item.title }}</a>
18+
</td>
19+
</tr>
20+
{%- endfor %}
21+
</table>
22+
</div>
23+
{%- else -%}
24+
<p>No posts so far...</p>
25+
{%- endif %}
26+
</div>

_includes/news.html

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
1+
22
<div class="news">
3-
{% if site.news != blank -%}
3+
{% if site.news != blank -%}
44
{%- assign news_size = site.news | size -%}
5-
<div class="table-responsive" {% if site.news_scrollable and news_size > 3 %}style="max-height: 10vw"{% endif %}>
5+
<div class="table-responsive" {% if site.news.scrollable and news_size > 3 %}style="max-height: 10vw"{% endif %}>
66
<table class="table table-sm table-borderless">
77
{%- assign news = site.news | reverse -%}
8-
{% if site.news_limit %}
9-
{% assign news_limit = site.news_limit %}
8+
{% if site.news.limit %}
9+
{% assign news_limit = site.news.limit %}
1010
{% else %}
1111
{% assign news_limit = news_size %}
1212
{% endif %}
13-
{% for item in news limit: news_limit %}
13+
{% for item in news limit: news_limit %}
1414
<tr>
1515
<th scope="row">{{ item.date | date: "%b %-d, %Y" }}</th>
1616
<td>
17-
{% if item.inline -%}
17+
{% if item.inline -%}
1818
{{ item.content | remove: '<p>' | remove: '</p>' | emojify }}
19-
{%- else -%}
19+
{%- else -%}
2020
<a class="news-title" href="{{ item.url | relative_url }}">{{ item.title }}</a>
21-
{%- endif %}
21+
{%- endif %}
2222
</td>
2323
</tr>
24-
{%- endfor %}
24+
{%- endfor %}
2525
</table>
2626
</div>
27-
{%- else -%}
27+
{%- else -%}
2828
<p>No news so far...</p>
29-
{%- endif %}
29+
{%- endif %}
3030
</div>

_layouts/about.html

+9-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ <h1 class="post-title">
2323
{%- assign profile_image_class = "img-fluid z-depth-1 rounded" -%}
2424
{% endif %}
2525

26-
{% include figure.html
27-
path=profile_image_path
26+
{% include figure.html
27+
path=profile_image_path
2828
class=profile_image_class
2929
alt=page.profile.image -%}
3030
{% endif -%}
@@ -46,6 +46,12 @@ <h2><a href="{{ '/news/' | relative_url }}" style="color: inherit;">news</a></h2
4646
{%- include news.html %}
4747
{%- endif %}
4848

49+
<!-- Latest posts -->
50+
{% if page.latest_posts -%}
51+
<h2><a href="{{ '/blog/' | relative_url }}" style="color: inherit;">latest posts</a></h2>
52+
{%- include latest_posts.html %}
53+
{%- endif %}
54+
4955
<!-- Selected papers -->
5056
{% if page.selected_papers -%}
5157
<h2><a href="{{ '/publications/' | relative_url }}" style="color: inherit;">selected publications</a></h2>
@@ -62,7 +68,7 @@ <h2><a href="{{ '/publications/' | relative_url }}" style="color: inherit;">sele
6268
<div class="contact-note">
6369
{{ site.contact_note }}
6470
</div>
65-
71+
6672
</div>
6773
{%- endif %}
6874
</article>

_pages/about.md

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ profile:
1414
<p>Your City, State 12345</p>
1515
1616
news: true # includes a list of news items
17+
latest_posts: true # includes a list of the newest posts
1718
selected_papers: true # includes a list of papers marked as "selected={true}"
1819
social: true # includes social icons at the bottom of the page
1920
---

0 commit comments

Comments
 (0)