add: link prepend
This commit is contained in:
parent
f13433fc4b
commit
4e61e4acb3
1 changed files with 15 additions and 0 deletions
15
prepends/link.typ
Normal file
15
prepends/link.typ
Normal 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
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue