Skip to content

Commit d66d8a1

Browse files
committed
Post metadata separated into partial. FontAwesome optimized.
1 parent ce76cd9 commit d66d8a1

8 files changed

Lines changed: 64 additions & 49 deletions

File tree

_includes/layouts/base.njk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
{%- css %}{% include "public/css/index.css" %}{% endcss %}
77

8-
{%- css %}{% include "node_modules/@fortawesome/fontawesome-free/css/all.min.css" %}{% endcss %}
8+
{%- css %}{% include "node_modules/@fortawesome/fontawesome-free/css/svg-with-js.min.css" %}{% endcss %}
99
{%- js %}{% include "node_modules/@fortawesome/fontawesome-free/js/all.min.js" %}{% endjs %}
1010

1111
{%- js %}{% include "node_modules/@zachleat/heading-anchors/heading-anchors.js" %}{% endjs %}

_includes/layouts/post.njk

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@ layout: layouts/base.njk
1717
.links-nextprev-next {
1818
text-align: right;
1919
}
20-
.post-metadata {
21-
display: inline-flex;
22-
flex-wrap: wrap;
23-
gap: 2em;
24-
list-style: none;
25-
padding: 0;
26-
margin: 0;
27-
}
28-
.tag {
29-
border: 1px solid var(--border-color);
30-
border-radius: 4px;
31-
background-color: var(--bg-color-secondary);
32-
padding: 0 0.25rem;
33-
transition: background-color 0.3s, border-color 0.3s;
34-
}
3520

3621
.post-header {
3722
margin-top: 1.5rem;
@@ -41,23 +26,7 @@ layout: layouts/base.njk
4126
<article>
4227
<h1>{{ title }}</h1>
4328

44-
<ul class="post-metadata">
45-
<div>
46-
<i class="fa-regular fa-calendar"></i>
47-
<time datetime="{{ page.date | isoDate }}">{{ page.date | readableDate }}</time>
48-
</div>
49-
<div data-words="{{ content | striptags | wordcount | formatWords }} words">
50-
<i class="fa-regular fa-clock"></i>
51-
{{ content | striptags | wordcount | readingTime }}
52-
</div>
53-
<div>
54-
<i class="fa-solid fa-tags"></i>
55-
{%- for tag in tags | filterTagList %}
56-
{%- set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
57-
<span class="tag"><a href="{{ tagUrl }}">{{ tag }}</a></span>
58-
{%- endfor %}
59-
</div>
60-
</ul>
29+
{% include "./../partials/post-meta.njk" %}
6130

6231
{%- if image %}
6332
<img src="{{ image }}" alt="" class="post-header" />

_includes/partials/header.njk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ header:after {
3232
.header-right a {
3333
color: var(--text-color) !important;
3434
margin-left: 0.5rem;
35+
transition: background-color 0.3s, color 0.3s;
3536
}
3637
.header-right a:hover {
3738
color: var(--link-color-hover) !important;
@@ -68,8 +69,7 @@ header:after {
6869
text-decoration: none;
6970
}
7071
.nav a[href][aria-current="page"] {
71-
text-decoration: underline;
72-
font-weight: 600;
72+
font-weight: 700;
7373
}
7474

7575
.toggle-dark {

_includes/partials/pagination.njk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
color: var(--link-color-hover);
3232
text-decoration: none;
3333
box-shadow: 0 2px 4px 2px var(--shadow-color);
34-
transition: background-color 0.3s, color 0.3s, box-shadow 0.3s;
3534
}
3635

3736
.pagination li.active a {

_includes/partials/post-card.njk

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{% css %}
2-
.post-card-meta
2+
.post-card
33
{
4-
margin-top: 0.5rem;
5-
gap: 2rem;
4+
display: flex;
5+
flex-direction: column;
6+
gap: 1rem;
7+
margin-bottom: 2rem;
8+
}
9+
10+
.post-card h2 {
11+
margin-top: 0;
12+
margin-bottom: 0;
613
}
714
{% endcss %}
815

916
<div class="post-card">
1017
<h2><a href="{{ post.url }}">{% if post.data.title %}{{ post.data.title }}{% else %}<code>{{ post.url }}</code>{% endif %}</a></h2>
1118
<div class="excerpt"><em>{{ post | excerpt | truncate(500) }}</em></div>
12-
<div class="flex post-card-meta">
13-
<div>
14-
<i class="fa-regular fa-calendar"></i> <time datetime="{{ post.date | isoDate }}">{{ post.date | readableDate }}</time>
15-
</div>
16-
<div data-words="{{ post.templateContent | striptags | wordcount | formatWords }} words">
17-
<i class="fa-regular fa-clock"></i> {{ post.templateContent | striptags | wordcount | readingTime }}
18-
</div>
19-
</div>
19+
{% include "./post-meta.njk" %}
2020
</div>

_includes/partials/post-meta.njk

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{% css %}
2+
.post-metadata {
3+
display: inline-flex;
4+
flex-wrap: wrap;
5+
gap: 2em;
6+
list-style: none;
7+
padding: 0;
8+
margin: 0;
9+
}
10+
.post-metadata .tag {
11+
border: 1px solid var(--border-color);
12+
border-radius: 4px;
13+
background-color: var(--bg-color-secondary);
14+
padding: 0 0.25rem;
15+
transition: background-color 0.3s, border-color 0.3s;
16+
}
17+
18+
.post-metadata svg {
19+
margin-right: 0.25rem;
20+
}
21+
{% endcss %}
22+
23+
{% set post = collections.posts | getCollectionItem %}
24+
25+
<div class="post-metadata">
26+
<div>
27+
<i class="fa-regular fa-calendar"></i>
28+
<time datetime="{{ post.date | isoDate }}">{{ post.date | readableDate }}</time>
29+
</div>
30+
<div data-words="{{ post.templateContent | striptags | wordcount | formatWords }} words">
31+
<i class="fa-regular fa-clock"></i>
32+
{{ post.templateContent | striptags | wordcount | readingTime }}
33+
</div>
34+
<div>
35+
{% set tags = post.data.tags | filterTagList %}
36+
{% if tags.length > 0 %}
37+
<i class="fa-solid fa-tags"></i>
38+
{%- for tag in tags %}
39+
{%- set tagUrl %}/tags/{{ tag | slugify }}/{% endset %}
40+
<span class="tag"><a href="{{ tagUrl }}">{{ tag }}</a></span>
41+
{%- endfor %}
42+
{% endif %}
43+
</div>
44+
</div>

_includes/partials/socials.njk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
gap: 0.5rem;
1111
flex-direction: row-reverse;
1212
align-items: center;
13+
margin-top: 2rem;
14+
margin-bottom: 1rem;
1315
}
1416
.social a {
1517
margin: 0.25rem;
@@ -18,6 +20,7 @@
1820
color: var(--svg-color) !important;
1921
font-size: 1.5rem;
2022
cursor: pointer;
23+
transition: background-color 0.3s, color 0.3s;
2124
}
2225
.social a:hover {
2326
color: var(--link-color-hover) !important;

eleventy.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default async function(eleventyConfig) {
2727
// For example, `./public/css/` ends up in `_site/css/`
2828
eleventyConfig
2929
.addPassthroughCopy({
30-
"./public": "/"
30+
"./public": "/",
3131
})
3232
.addPassthroughCopy("./content/feed/pretty-atom-feed.xsl");
3333

@@ -124,7 +124,7 @@ export default async function(eleventyConfig) {
124124
// to emulate the file copy on the dev server. Learn more:
125125
// https://www.11ty.dev/docs/copy/#emulate-passthrough-copy-during-serve
126126

127-
eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
127+
// eleventyConfig.setServerPassthroughCopyBehavior("passthrough");
128128
};
129129

130130
export const config = {

0 commit comments

Comments
 (0)