feat(home): add latest projects and posts section
This commit is contained in:
@@ -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;
|
||||
|
@@ -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 %}…{% 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 %}
|
||||
|
||||
|
Reference in New Issue
Block a user