Implemented latest posts on about page (#1307)

Adresses #340

---------

Signed-off-by: George Araújo <george.gcac@gmail.com>
This commit is contained in:
George 2023-04-08 10:19:08 -03:00 committed by GitHub
parent 5ff54a74ef
commit 60209cfd93
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 57 additions and 17 deletions

View File

@ -174,8 +174,15 @@ collections:
output: true
permalink: /projects/:path/
news_scrollable: true # adds a vertical scroll bar if there are more than 3 news items
news_limit: 5 # leave blank to include all the news in the `_news` folder
news:
enabled: true
scrollable: true # adds a vertical scroll bar if there are more than 3 news items
limit: 5 # leave blank to include all the news in the `_news` folder
latest_posts:
enabled: true
scrollable: true # adds a vertical scroll bar if there are more than 3 new posts items
limit: 3 # leave blank to include all the blog posts
# -----------------------------------------------------------------------------
# Jekyll settings

View File

@ -0,0 +1,26 @@
<div class="news">
{% if site.latest_posts != blank -%}
{%- assign latest_posts_size = site.posts | size -%}
<div class="table-responsive" {% if site.latest_posts.scrollable and latest_posts_size > 3 %}style="max-height: 10vw"{% endif %}>
<table class="table table-sm table-borderless">
{%- assign latest_posts = site.posts -%}
{% if site.latest_posts.limit %}
{% assign latest_posts_limit = site.latest_posts.limit %}
{% else %}
{% assign latest_posts_limit = latest_posts_size %}
{% endif %}
{% for item in latest_posts limit: latest_posts_limit %}
<tr>
<th scope="row">{{ item.date | date: "%b %-d, %Y" }}</th>
<td>
<a class="news-title" href="{{ item.url | relative_url }}">{{ item.title }}</a>
</td>
</tr>
{%- endfor %}
</table>
</div>
{%- else -%}
<p>No posts so far...</p>
{%- endif %}
</div>

View File

@ -1,30 +1,30 @@
<div class="news">
{% if site.news != blank -%}
{% if site.news != blank -%}
{%- assign news_size = site.news | size -%}
<div class="table-responsive" {% if site.news_scrollable and news_size > 3 %}style="max-height: 10vw"{% endif %}>
<div class="table-responsive" {% if site.news.scrollable and news_size > 3 %}style="max-height: 10vw"{% endif %}>
<table class="table table-sm table-borderless">
{%- assign news = site.news | reverse -%}
{% if site.news_limit %}
{% assign news_limit = site.news_limit %}
{% if site.news.limit %}
{% assign news_limit = site.news.limit %}
{% else %}
{% assign news_limit = news_size %}
{% endif %}
{% for item in news limit: news_limit %}
{% for item in news limit: news_limit %}
<tr>
<th scope="row">{{ item.date | date: "%b %-d, %Y" }}</th>
<td>
{% if item.inline -%}
{% if item.inline -%}
{{ item.content | remove: '<p>' | remove: '</p>' | emojify }}
{%- else -%}
{%- else -%}
<a class="news-title" href="{{ item.url | relative_url }}">{{ item.title }}</a>
{%- endif %}
{%- endif %}
</td>
</tr>
{%- endfor %}
{%- endfor %}
</table>
</div>
{%- else -%}
{%- else -%}
<p>No news so far...</p>
{%- endif %}
{%- endif %}
</div>

View File

@ -23,8 +23,8 @@ layout: default
{%- assign profile_image_class = "img-fluid z-depth-1 rounded" -%}
{% endif %}
{% include figure.html
path=profile_image_path
{% include figure.html
path=profile_image_path
class=profile_image_class
alt=page.profile.image -%}
{% endif -%}
@ -46,6 +46,12 @@ layout: default
{%- include news.html %}
{%- endif %}
<!-- Latest posts -->
{% if page.latest_posts -%}
<h2><a href="{{ '/blog/' | relative_url }}" style="color: inherit;">latest posts</a></h2>
{%- include latest_posts.html %}
{%- endif %}
<!-- Selected papers -->
{% if page.selected_papers -%}
<h2><a href="{{ '/publications/' | relative_url }}" style="color: inherit;">selected publications</a></h2>
@ -62,7 +68,7 @@ layout: default
<div class="contact-note">
{{ site.contact_note }}
</div>
</div>
{%- endif %}
</article>

View File

@ -14,6 +14,7 @@ profile:
<p>Your City, State 12345</p>
news: true # includes a list of news items
latest_posts: true # includes a list of the newest posts
selected_papers: true # includes a list of papers marked as "selected={true}"
social: true # includes social icons at the bottom of the page
---