-
Notifications
You must be signed in to change notification settings - Fork 668
Expand file tree
/
Copy pathrecent_news.html
More file actions
60 lines (52 loc) · 2.31 KB
/
recent_news.html
File metadata and controls
60 lines (52 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{% comment %}
Recent News component for news post pages
Displays latest news posts excluding the current post
{% endcomment %}
{% if site.data.locales[page.lang].news %}
{% assign news_locale = site.data.locales[page.lang].news %}
{% else %}
{% assign news_locale = site.data.locales['en'].news %}
{% endif %}
{% comment %}Get recent news posts (excluding current post and security posts){% endcomment %}
{% assign recent_posts = '' | split: '' %}
{% for post in site.categories[page.lang] %}
{% unless post.url == page.url %}
{% unless post.tags contains 'security' %}
{% if recent_posts.size < 4 %}
{% assign recent_posts = recent_posts | push: post %}
{% endif %}
{% endunless %}
{% endunless %}
{% if recent_posts.size >= 4 %}
{% break %}
{% endif %}
{% endfor %}
{% if recent_posts.size > 0 %}
<section class="not-prose mt-16 p-6 md:p-8 border border-stone-200 dark:border-stone-700 rounded-xl">
<h2 class="text-2xl font-bold mb-6">
<a href="/{{ page.lang }}/news/" class="text-stone-900 dark:text-stone-100 hover:text-ruby-600 dark:hover:text-ruby-400 transition-colors inline-flex items-center">
{{ news_locale.recent_news }}<span class="icon-chevron-right text-2xl" aria-hidden="true"></span>
</a>
</h2>
<div class="space-y-4">
{% for post in recent_posts %}
<article class="pb-4 border-b border-stone-200 dark:border-stone-700 last:border-b-0">
<h3 class="text-lg font-bold mb-2"{% if post.fallback %} lang="en"{% endif %}>
<a href="{{ post.url }}" class="text-stone-900 dark:text-stone-100 hover:text-ruby-600 dark:hover:text-ruby-400 transition-colors">
{{ post.title }}
</a>
</h3>
<p class="text-stone-600 dark:text-stone-400 text-sm mb-2 line-clamp-2"{% if post.fallback %} lang="en"{% endif %}>
{{ post.excerpt | strip_html | truncatewords: 25 }}
</p>
<p class="text-xs text-stone-500 dark:text-stone-400">{{ post.date | posted_by:post.author }}</p>
</article>
{% endfor %}
</div>
<p class="mt-6">
<a href="/{{ page.lang }}/news/" class="text-sm text-semantic-text-link hover:text-semantic-text-link-hovered transition-colors inline-flex items-center gap-1">
{{ news_locale.more_news }}<span class="icon-chevron-right" aria-hidden="true"></span>
</a>
</p>
</section>
{% endif %}