feat: new archives; show only 10 recent at home

This commit is contained in:
Ayo Ayco 2024-05-14 02:03:20 +02:00
parent e8179ce799
commit 117bf0467c
4 changed files with 48 additions and 2 deletions

View file

@ -48,6 +48,8 @@ defaults:
navigation:
- text: Home
url: /
- text: "Archives"
url: /archives/
- text: "All Topics"
url: /categories/
- text: "About"
@ -150,3 +152,10 @@ prose:
# - vendor/cache/
# - vendor/gems/
# - vendor/ruby/
jekyll-archives:
enabled:
- year
layout: archive
permalinks:
year: 'archives/:year/'

14
_layouts/archive.html Normal file
View file

@ -0,0 +1,14 @@
---
layout: default
---
<h1>Archive of posts from {{ page.date | date: "%Y" }}</h1>
<ul class="posts">
{% for post in page.posts %}
<li>
<span class="post-date">{{ post.date | date: "%b %-d, %Y" }}</span>
<a class="post-link" href="{{ post.url | relative_url }}">{{ post.title }}</a>
</li>
{% endfor %}
</ul>

View file

@ -4,10 +4,14 @@ layout: default
<div class="blog-home">
<!-- {% include message.html %} -->
{% if site.posts.size > 0 %}
<ul class="blog-home__list-items">
{% for post in site.posts %} {% include post-item.html %} {% endfor %}
{% for post in site.posts limit:10 %}
{% include post-item.html %}
{% endfor %}
</ul>
{% endif %}
<p>
<strong>See more at <a href="/archives">the archives</a>.</strong>
</p>
</div>

19
archives.html Normal file
View file

@ -0,0 +1,19 @@
---
layout: category
category-name: entertainment
title: Entertainment Posts
permalink: /entertainment/
---
<h1>Entertainment Posts</h1>
<div class="blog-home">
{% if site.categories.entertainment.size > 0 %}
<ul class="blog-home__list-items">
{% for post in site.categories.entertainment %}{% include post-item.html %}
{% endfor %}
</ul>
{% else %}
<span>No posts to show.</span>
{% endif %}
</div>