typssg/prepends/article_link.typ
2026-06-11 14:56:56 -04:00

20 lines
383 B
Typst

#let article_link(path) = {
let file-path = path + "index.typ"
let content = read(file-path)
let title = none
for line in content.split("\n") {
let trimmed = line.trim()
if trimmed.starts-with("= ") {
title = trimmed.slice(2).trim()
break
}
}
if title == none {
panic("No level-1 heading found in " + file-path)
}
link(path)[#title]
}