put draft posts at the top

This commit is contained in:
Tom 2025-05-17 09:30:25 +01:00
parent f063d0394a
commit 6d6358b6a7
2 changed files with 18 additions and 6 deletions

12
blog.md
View File

@ -14,8 +14,16 @@ img:
<span class="dt-label">Date Posted</span> <span class="dt-label">Date Posted</span>
</section> </section>
<hr class="heading"> <hr class="heading">
{% for post in site.posts %}
{% if post.draft == false or jekyll.environment == "development" %} {% assign draft_posts = site.posts | where: "draft", "true" %}
{% assign published_posts = site.posts | where: "draft", "false" %}
{% if jekyll.environment == 'development' %}
{% for post in draft_posts %}
{% include post_summary.html %} {% include post_summary.html %}
{% endfor %}
{% endif %} {% endif %}
{% for post in published_posts limit:5 %}
{% include post_summary.html %}
{% endfor %} {% endfor %}

View File

@ -24,13 +24,17 @@ Welcome to my little home on the web! Below you'll find recent blog posts, proje
</section> </section>
<hr class="heading"> <hr class="heading">
{% assign draft_posts = site.posts | where: "draft", "true" %}
{% assign published_posts = site.posts | where: "draft", "false" %}
{% if jekyll.environment == 'development' %} {% if jekyll.environment == 'development' %}
{% assign filtered_posts = site.posts %} {% for post in draft_posts %}
{% else %} {% include post_summary.html %}
{% assign filtered_posts = site.posts | where: "draft", "false" %} {% endfor %}
{% endif %} {% endif %}
{% for post in filtered_posts limit:5 %} {% for post in published_posts limit:5 %}
{% include post_summary.html %} {% include post_summary.html %}
{% endfor %} {% endfor %}