Fixed news limit (#1359)

Fixes #1346.

---------

Signed-off-by: George Araujo <george.gcac@gmail.com>
Co-authored-by: Yifan Jiang <55911052+YifanJiang233@users.noreply.github.com>
Co-authored-by: Raffaele Mancuso <54762742+raffaem@users.noreply.github.com>
Co-authored-by: Yue Gao <11145354+Lodour@users.noreply.github.com>
This commit is contained in:
George 2023-04-27 12:26:48 -03:00 committed by GitHub
parent e8c5450790
commit 0b109a23ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

View File

@ -175,7 +175,7 @@ collections:
output: true
permalink: /projects/:path/
news:
announcements:
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

View File

@ -1,13 +1,11 @@
<div class="news">
{% 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: 60vw"{% endif %}>
<script>console.log({{news_size}});</script>
<div class="table-responsive" {% if include.limit and site.announcements.scrollable and news_size > 3 %}style="max-height: 60vw"{% endif %}>
<table class="table table-sm table-borderless">
{%- assign news = site.news | reverse -%}
{% if site.news.limit %}
{% assign news_limit = site.news.limit %}
{% if include.limit and site.announcements.limit %}
{% assign news_limit = site.announcements.limit %}
{% else %}
{% assign news_limit = news_size %}
{% endif %}

View File

@ -41,9 +41,9 @@ layout: default
</div>
<!-- News -->
{% if page.news -%}
{% if page.news and site.announcements.enabled -%}
<h2><a href="{{ '/news/' | relative_url }}" style="color: inherit;">news</a></h2>
{%- include news.html %}
{%- include news.html limit=true %}
{%- endif %}
<!-- Latest posts -->