add: link prepend

This commit is contained in:
andrew 2026-05-07 10:59:35 -04:00
parent f13433fc4b
commit 4e61e4acb3

15
prepends/link.typ Normal file
View file

@ -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
}
}