summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Fink2026-11-06 18:26:38 +0100
committerDennis Fink2026-11-06 18:26:38 +0100
commit2fc37fa4e2930e7c8603660301b1b0fe80a6c5a8 (patch)
treeea4161a44bf0f12258f2fb8b84e28b5e28a330ff
parent3ccac9a70669db5cd9d83a1d05b02e0c43cf58c6 (diff)
downloaddennisfink.me-2fc37fa4e2930e7c8603660301b1b0fe80a6c5a8.tar.gz
dennisfink.me-2fc37fa4e2930e7c8603660301b1b0fe80a6c5a8.zip
Add previous and next post navigation
This adds navigation links between adjacent blog posts, allowing readers to continue browsing without returning to the blog index. The navigation uses a responsive two-column layout and is excluded from Pagefind indexing.
-rw-r--r--assets/static/css/style.css59
-rw-r--r--templates/blog-post.html21
2 files changed, 75 insertions, 5 deletions
diff --git a/assets/static/css/style.css b/assets/static/css/style.css
index ec1318d..beb9cc3 100644
--- a/assets/static/css/style.css
+++ b/assets/static/css/style.css
@@ -687,7 +687,7 @@ article {
clear: both;
color: var(--dim-foreground);
font-style: italic;
- font-size: 1.2rem;
+ font-size: 0.75rem;
line-height: 1.5;
margin-top: 1.5rem;
@@ -706,16 +706,20 @@ article {
display: inline;
max-inline-size: none;
}
+
li:not(:first-child) {
white-space: nowrap;
}
- .changelog {
- font-size: 0.85rem;
+ li,
+ p {
+ font-size: 1.2rem;
+ }
+ .changelog {
& > h3 {
font-size: clamp(1.2rem, 2vw, 1.5rem);
- margin: 0 0 0.75rem;
+ margin: 1.5rem 0 0.75rem;
}
& > ul {
@@ -727,6 +731,7 @@ article {
display: grid;
grid-template-columns: max-content 1fr;
gap: 1rem;
+ font-size: 1.2rem;
& + li {
margin-top: 0.4rem;
@@ -734,6 +739,7 @@ article {
& > time {
color: var(--dim-blue);
+ min-width: 11rem;
}
}
}
@@ -831,6 +837,51 @@ nav:is(
/*
=============================================================================
+POST NAVIGATION
+=============================================================================
+*/
+nav[aria-label="Post navigation"] {
+ display: grid;
+ grid-template-columns: repeat(2, minmax(0, 1fr));
+ gap: 1.5rem;
+ margin-top: 1.5rem;
+
+ a {
+ display: flex;
+ flex-direction: column;
+ gap: 0.25rem;
+ overflow-wrap: anywhere;
+
+ &[rel="prev"] {
+ grid-column: 1;
+ }
+
+ &[rel="next"] {
+ grid-column: 2;
+ text-align: right;
+ }
+
+ small {
+ color: var(--dim-foreground);
+ font-size: 0.85rem;
+ }
+
+ span {
+ font-size: clamp(1rem, 1.5vw, 1.2rem);
+ }
+ }
+
+ @media (max-width: 500px) {
+ grid-template-columns: 1fr;
+
+ a[rel="next"] {
+ grid-column: 1;
+ }
+ }
+}
+
+/*
+=============================================================================
IMAGES
=============================================================================
*/
diff --git a/templates/blog-post.html b/templates/blog-post.html
index 6c74033..d08ed2f 100644
--- a/templates/blog-post.html
+++ b/templates/blog-post.html
@@ -93,4 +93,23 @@
{% endif %}
{% endblock %}
-{% block content %}{{ render_blog_post(this) }}{% endblock %}
+{% block content %}
+ {{ render_blog_post(this) }}
+ {% set siblings = this.get_siblings() %}
+ {% if siblings.next_page or siblings.prev_page %}
+ <nav aria-label="Post navigation" data-pagefind-ignore>
+ {% if siblings.next_page %}
+ <a href="{{ siblings.next_page | url }}" rel="prev">
+ <small>← Previous post</small>
+ <span>{{ siblings.next_page.title }}</span>
+ </a>
+ {% endif %}
+ {% if siblings.prev_page %}
+ <a href="{{ siblings.prev_page | url }}" rel="next">
+ <small>Next post →</small>
+ <span>{{ siblings.prev_page.title }}</span>
+ </a>
+ {% endif %}
+ </nav>
+ {% endif %}
+{% endblock %}