Skip to content

Commit caf110e

Browse files
authored
fix: article.njk — unpublish posts are showing up (#281)
fix: `article.njk` — unpublish posts are showing up
2 parents 0cf16d3 + 47391c3 commit caf110e

File tree

1 file changed

+48
-23
lines changed

1 file changed

+48
-23
lines changed

src/_includes/layouts/article.njk

Lines changed: 48 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,46 @@
22
layout: 'layouts/secondary.njk'
33
style: 'article.css'
44
---
5+
56
{% set previousPost = collections.post | getPreviousCollectionItem(page) %}
67
{% set nextPost = collections.post | getNextCollectionItem(page) %}
7-
88
<header class="header header_article">
9-
<img width="1920" height="1080" loading="lazy" src="{{ image }}" alt="{{ title }}">
9+
<img width="1920"
10+
height="1080"
11+
loading="lazy"
12+
src="{{ image }}"
13+
alt="{{ title }}">
1014
</header>
1115
<main class="main">
1216
<div class="main-container">
1317
<article class="article">
1418
<header>
1519
<span>
1620
<a class="breadcrumb" href="/">Home</a> ›
17-
<a class="breadcrumb" href="/blog">Blog</a> › {{ title }}
21+
<a class="breadcrumb" href="/blog">Blog</a> › <span aria-current="page">{{ title }}</span>
1822
</span>
1923
<h1 class="article-title" id="{{ title | slug }}">{{ title }}</h1>
2024
<p class="article-summary">{{ description }}</p>
2125
<div class="article-detail_list article-flex_list">
2226
<div class="article-detail_item">
23-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
24-
stroke="currentColor" class="article-detail_item_svg">
25-
<path stroke-linecap="round" stroke-linejoin="round"
26-
d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" />
27+
<svg xmlns="http://www.w3.org/2000/svg"
28+
fill="none"
29+
viewBox="0 0 24 24"
30+
stroke-width="1.5"
31+
stroke="currentColor"
32+
class="article-detail_item_svg">
33+
<path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" />
2734
</svg>
2835
{{ author }}
2936
</div>
3037
<div class="article-detail_item">
31-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5"
32-
stroke="currentColor" class="article-detail_item_svg">
33-
<path stroke-linecap="round" stroke-linejoin="round"
34-
d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5" />
38+
<svg xmlns="http://www.w3.org/2000/svg"
39+
fill="none"
40+
viewBox="0 0 24 24"
41+
stroke-width="1.5"
42+
stroke="currentColor"
43+
class="article-detail_item_svg">
44+
<path stroke-linecap="round" stroke-linejoin="round" d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5" />
3545
</svg>
3646
<time datetime="{{ date | htmlDateString }}">{{ date | postDate }}</time>
3747
</div>
@@ -41,21 +51,36 @@ style: 'article.css'
4151
{{ content | safe }}
4252
</main>
4353
<section class="more">
44-
{% if nextPost %}
45-
<div class="more-next">
46-
← Next Post<br /> <a href="{{ nextPost.url }}">{{ nextPost.data.title }}
47-
</a>
48-
</div>
54+
{% if not nextPost.data.draft and nextPost %}
55+
<div class="more-next">
56+
← Next Post
57+
<br />
58+
<a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a>
59+
</div>
4960
{% endif %}
50-
{% if previousPost %}
51-
<div class="more-previous">
52-
Previous Post →<br /> <a href="{{ previousPost.url }}">{{ previousPost.data.title }}
53-
</a>
54-
</div>
61+
{% if nextPost and isDevelopment and nextPost.data.draft %}
62+
<div class="more-next">
63+
← Next Post <i>(Draft)</i>
64+
<br />
65+
<a href="{{ nextPost.url }}">{{ nextPost.data.title }}</a>
66+
</div>
67+
{% endif %}
68+
{% if not previousPost.data.draft and previousPost %}
69+
<div class="more-previous">
70+
Previous Post →
71+
<br />
72+
<a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a>
73+
</div>
74+
{% endif %}
75+
{% if previousPost and isDevelopment and previousPost.data.draft %}
76+
<div class="more-next">
77+
Previous Post <i>(Draft)</i> →
78+
<br />
79+
<a href="{{ previousPost.url }}">{{ previousPost.data.title }}</a>
80+
</div>
5581
{% endif %}
5682
</section>
5783
</article>
5884
</div>
5985
</main>
60-
61-
<script src="/js/blog.js"></script>
86+
<script src="/js/blog.js"></script>

0 commit comments

Comments
 (0)