borkdude / quickblog

Light-weight static blog engine for Clojure and babashka
https://blog.michielborkent.nl/
MIT License
165 stars 28 forks source link

Add an option to link previous and next posts in post metadata #95

Closed jmglov closed 7 months ago

jmglov commented 7 months ago

If you set the :link-prev-next-posts option to true, quickblog adds prev and next metadata to each post (where prev is the previous post and next is the next post in date order, oldest to newest). You can make use of these by adding something similar to this to your post.html template:

{% if any prev next %}
  <div class="post-prev-next">
{% if prev %}
    <div>⏪ <a href="{{prev.file|replace:.md:.html}}">{{prev.title}}</a></div>
{% endif %}
{% if next %}
    <div><a href="{{next.file|replace:.md:.html}}">{{next.title}}</a> ⏩</div>
{% endif %}
  </div>
{% endif %}
borkdude commented 7 months ago

Thanks a lot