feat(home): add latest projects and posts section

This commit is contained in:
2025-08-27 17:06:26 +02:00
parent eb2bd6413d
commit f328bcbb54
2 changed files with 54 additions and 0 deletions

View File

@@ -24,6 +24,27 @@
display: none;
}
}
.latest-projects-posts {
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
gap: 1rem;
margin-top: 5rem;
.project {
display: flex;
flex-direction: column;
margin: 1rem 30%;
gap: 1rem;
.title {
font-size: 1.2rem;
}
.description {
font-size: 1rem;
}
}
}
@media (max-width: 600px) {
#pgp {
display: none;

View File

@@ -22,5 +22,38 @@
</script>
</section>
{# how many items to show #}
{% set n = 6 %}
{# fetch sections #}
{% set posts = get_section(path="posts/_index.md") %}
{% set projects = get_section(path="projects/_index.md") %}
{# merge, sort by date (desc), take first n #}
{% set latest = posts.pages
| concat(with=projects.pages)
| sort(attribute="date")
| reverse
| slice(end=n)
%}
<section class="latest-projects-posts">
<h2>Latest projects & posts</h2>
{% for page in latest %}
<div class="project">
<a class="title" href="{{ page.permalink }}">{{ page.title }}</a>
<p class="description">
{% if page.description %}{{ page.description }}{% else %}&hellip;{% endif %}
</p>
<hr>
<p>
{{ page.date }}
{% if page.path is starting_with("posts/") %} · Post
{% elif page.path is starting_with("projects/") %} · Project
{% endif %}
</p>
</div>
{% endfor %}
</section>
{% endblock content %}