jorge/docs/layouts/post.html
Facundo Olano c02e1fc91e
Add page.previous and page.next liquid variables (#22)
* sort pages

* rename tutorial files to enforce an order

* add prev next props to posts

* test previous next

* prevent nested recursive links between posts

* add a next/prev footer

* make prev/next work as expected for both pages and posts

* remove sort by index

* bold current section in nav
2024-03-02 16:16:40 -03:00

40 lines
1.3 KiB
HTML

---
layout: base
---
{% include nav.html %}
<div class="layout-{{ page.layout }}" lang="{{ page.lang | default:site.config.lang | default:'en' }}">
<header {% if page.cover-img %}class="with-cover"{% endif %}>
<h1 class="title">{{ page.title }}</h1>
{% if page.subtitle %}<h3 class="subtitle">{{ page.subtitle }}</h3>{% endif %}
{% if page.cover-img %}
<img class="cover-img" src="{{ page.cover-img | absolute_url }}">
{% endif %}
</header>
{{ content }}
<br/>
<br/>
{% comment%}
if page.date then it's a post, and we want to invert the prev/next for the controls:
the next arrow should take you to the newer post, which appears fist in the site.posts list.
{%endcomment%}
{% if page.date %}
{% assign previous = page.next %}
{% assign next = page.previous %}
{% else %}
{% assign previous = page.previous %}
{% assign next = page.next %}
{% endif %}
<div class="pagination" style="display:flex">
{% if previous %}
<span><a class="title" href="{{previous.url}}"> {{ previous.subtitle | default:previous.title}}</a></span>
{% endif %}
{% if next %}
<span style="margin-left: auto"><a class="title" href="{{next.url}}">{{ next.subtitle | default:next.title}}</a></p>
{% endif %}
</div>
</div>