aboutsummaryrefslogtreecommitdiff
path: root/global/common.typ
diff options
context:
space:
mode:
authorKumar Damani <me@kumardamani.net>2026-08-03 16:38:58 +0000
committerKumar Damani <me@kumardamani.net>2026-08-03 16:38:58 +0000
commit7ccfffa85f120026e65d33bbac4b5735b8dd34bf (patch)
treebeeb4f7e7b91e17a5f5f3a3a47022733c5cf4dd2 /global/common.typ
parentb88879f6b56e5b2465089a50d63d89a7c1ee5dd6 (diff)
added prev./next navigation to posts
Diffstat (limited to 'global/common.typ')
-rw-r--r--global/common.typ22
1 files changed, 22 insertions, 0 deletions
diff --git a/global/common.typ b/global/common.typ
index bc5731e..f5f5c6d 100644
--- a/global/common.typ
+++ b/global/common.typ
@@ -131,6 +131,26 @@
link(label-for(id), _preferred-title(id))
}
+// Prev/next links between posts, shown at the bottom of post pages. Posts
+// are ordered newest-first in site-info.pages; prev points to the older
+// post, next to the newer one.
+#let post-nav(pages, current) = {
+ let posts = pages.keys().filter(k => k.starts-with("post/"))
+ let i = posts.position(k => k == current)
+
+ let prev = if i + 1 < posts.len() { posts.at(i + 1) }
+ let next = if i > 0 { posts.at(i - 1) }
+
+ html.elem("nav", attrs: (class: "post-nav"), {
+ html.elem("span", if prev != none {
+ link(label-for(prev), [← prev])
+ })
+ html.elem("span", if next != none {
+ link(label-for(next), [next →])
+ })
+ })
+}
+
#let page(
pagename,
site-info,
@@ -228,4 +248,6 @@
page-date
body
+
+ post-nav(site-info.pages, pagename)
})