Skip to content

Commit

Permalink
Fixed news limit (alshedivat#1359)
Browse files Browse the repository at this point in the history
Fixes alshedivat#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>
  • Loading branch information
4 people authored and wangmagg committed May 14, 2024
1 parent 919d6c2 commit 28fc701
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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
Expand Down
10 changes: 4 additions & 6 deletions _includes/news.html
Original file line number Diff line number Diff line change
@@ -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 %}
Expand All @@ -28,4 +26,4 @@
{%- else -%}
<p>No news so far...</p>
{%- endif %}
</div>
</div>
4 changes: 2 additions & 2 deletions _layouts/about.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ <h1 class="post-title">
</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 -->
Expand Down

0 comments on commit 28fc701

Please sign in to comment.