feat: added next and last post links
This commit is contained in:
parent
bf11f1dd39
commit
0a55d89c7c
3 changed files with 86 additions and 1 deletions
|
|
@ -28,9 +28,45 @@ pageType: post
|
|||
<h2>Tags</h2>
|
||||
<ul class="tag-list">
|
||||
{% for tag in postTags %}
|
||||
<li><a href="/tags/{{ tag | lower }}/">#{{ tag }}</a></li>
|
||||
<li><a href="/tags/{{ tag | lower }}/\">#{{ tag }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</section>
|
||||
{% endif %}
|
||||
|
||||
{% set currentIndex = -1 %}
|
||||
{% for post in collections.posts %}
|
||||
{% if post.url == page.url %}
|
||||
{% set currentIndex = loop.index0 %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if currentIndex >= 0 %}
|
||||
{% set prevPost = collections.posts[currentIndex - 1] if currentIndex > 0 else null %}
|
||||
{% set nextPost = collections.posts[currentIndex + 1] if currentIndex < collections.posts.length - 1 else null %}
|
||||
|
||||
<nav class="post-navigation" aria-label="Post navigation">
|
||||
{% if prevPost %}
|
||||
<a href="{{ prevPost.url }}" class="post-nav-link post-nav-prev">
|
||||
<span class="post-nav-label">← Previous Post</span>
|
||||
<span class="post-nav-title">{{ prevPost.data.title }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="post-nav-link post-nav-prev post-nav-disabled">
|
||||
<span class="post-nav-label">← Previous Post</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
|
||||
{% if nextPost %}
|
||||
<a href="{{ nextPost.url }}" class="post-nav-link post-nav-next">
|
||||
<span class="post-nav-label">Next Post →</span>
|
||||
<span class="post-nav-title">{{ nextPost.data.title }}</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<span class="post-nav-link post-nav-next post-nav-disabled">
|
||||
<span class="post-nav-label">Next Post →</span>
|
||||
</span>
|
||||
{% endif %}
|
||||
</nav>
|
||||
{% endif %}
|
||||
</article>
|
||||
Loading…
Add table
Add a link
Reference in a new issue