From 4e61e4acb3135c08abc6cf16f1a1e48fd8d3dcc0 Mon Sep 17 00:00:00 2001 From: andrew Date: Thu, 7 May 2026 10:59:35 -0400 Subject: [PATCH] add: link prepend --- prepends/link.typ | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 prepends/link.typ diff --git a/prepends/link.typ b/prepends/link.typ new file mode 100644 index 0000000..ad107f9 --- /dev/null +++ b/prepends/link.typ @@ -0,0 +1,15 @@ +// Adds an "internal" class to links that stay within the application, +// allowing them to be styled differently from external links. +#show link: it => { + let dest = it.dest + if type(dest) == str { + let is-internal = dest.starts-with("/") or dest.starts-with(".") + let attrs = (href: dest) + if is-internal { + attrs = (href: dest, class: "internal") + } + html.elem("a", attrs: attrs, it.body) + } else { + it + } +}