aboutsummaryrefslogtreecommitdiff
path: root/global/common.typ
diff options
context:
space:
mode:
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)
})