Add posts section

This commit is contained in:
Neil Brommer 2023-07-07 16:42:16 -07:00
parent 747c6d7844
commit ab9068c833
6 changed files with 55 additions and 6 deletions

View file

@ -36,10 +36,12 @@
{% set standalonePages = collections.all | filterDrafts | IsNotMainPageSection | eleventyNavigation %}
{% if standalonePages | length %}
<li><hr /></li>
{% for standalonePage in standalonePages %}
<li {% if standalonePage.url == page.url %}class="active"{% endif %}>
{# select the page on sub-pages #}
<li {% if page.url and page.url.startsWith(standalonePage.url) %}class="active"{% endif %}>
<a href="{{ standalonePage.url }}">
{% if standalonePage.icon is defined %}
<svg class="bi" fill="currentColor" role="img">

21
src/posts/index.njk Normal file
View file

@ -0,0 +1,21 @@
---
title: Posts
eleventyNavigation:
key: Posts
icon: pencil
order: 1
---
{% if collections.posts | filterDrafts | IsNotPage(page.url) | length %}
{% for post in collections.posts | filterDrafts | IsNotPage(page.url) | reverse %}
<section>
<h2><a href={{ post.url }}>{{ post.data.title }}</a></h2>
<div>
{{ post.date.toLocaleDateString("en-US") }}
</div>
<p>{{ post.data.description }}</p>
</section>
{% endfor %}
{% else %}
<p>No posts</p>
{% endif %}

8
src/posts/post1.md Normal file
View file

@ -0,0 +1,8 @@
---
title: Post 1
description: Post 1 description
date: git Created
draft: true
---
Post 1 content

8
src/posts/post2.md Normal file
View file

@ -0,0 +1,8 @@
---
title: Post 2
description: Post 2 description
date: git Created
draft: true
---
Post 2 content

View file

@ -0,0 +1,3 @@
{
"tags": [ "posts" ]
}