feat: created basic blog layout
This commit is contained in:
parent
42fd071301
commit
0d41db36ef
13 changed files with 935 additions and 3 deletions
36
post-redirects.njk
Normal file
36
post-redirects.njk
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
---
|
||||
pagination:
|
||||
data: collections.postsBySlug
|
||||
size: 1
|
||||
alias: slugData
|
||||
resolve: keys
|
||||
permalink: /post/{{ slugData }}/
|
||||
layout: base.njk
|
||||
---
|
||||
|
||||
{% set posts = collections.postsBySlug[slugData] %}
|
||||
|
||||
{% if posts.length == 1 %}
|
||||
{# Single post - redirect to the dated version #}
|
||||
<meta http-equiv="refresh" content="0; url=/post/{{ slugData }}/{{ posts[0].data.createdAt | isoDate }}/">
|
||||
<script>window.location.href = "/post/{{ slugData }}/{{ posts[0].data.createdAt | isoDate }}/";</script>
|
||||
<p>Redirecting to <a href="/post/{{ slugData }}/{{ posts[0].data.createdAt | isoDate }}/">{{ posts[0].data.title }}</a>...</p>
|
||||
{% else %}
|
||||
{# Multiple posts with same title - show disambiguation page #}
|
||||
<h1>{{ posts[0].data.title }}</h1>
|
||||
<p>There are multiple posts with this title. Please select the one you're looking for:</p>
|
||||
|
||||
<ul class="post-list">
|
||||
{% for post in posts %}
|
||||
<li>
|
||||
<a href="/post/{{ slugData }}/{{ post.data.createdAt | isoDate }}/" class="post-card">
|
||||
<h2>{{ post.data.title }}</h2>
|
||||
<time datetime="{{ post.data.createdAt | dateFormat }}">{{ post.data.createdAt | dateFormat }}</time>
|
||||
{% if post.data.description %}
|
||||
<p>{{ post.data.description }}</p>
|
||||
{% endif %}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue