#import "metadata.typ": author-text, format-date, date-key #import "pdf.typ": pdf-header #let post-header(ctx) = [ #context { let info = ctx.page if target() == "html" { html.elem("header", attrs: (class: "content-box post-header"))[ #if info.title != none { html.h1(info.title) } #if info.subtitle != none { html.p(class: "post-subtitle", info.subtitle) } #if info.by.len() > 0 { html.p(class: "post-author", [By #author-text(info.by)]) } #if info.date != none { let time = html.elem("time", attrs: (datetime: date-key(info)), format-date(info.date)) html.p(class: "post-date", time) } #if info.description != none { html.p(info.description) } ] } else { pdf-header(ctx) } } ] #let post-card(ctx, info) = context { let title = if info.title == none { [Untitled post] } else { info.title } let by = if info.author == ctx.site.by.map(author => author.name) { () } else { info.by } if target() != "html" { return list.item[ #link(info.url, title) #if info.date != none [— #format-date(info.date)] #if by.len() > 0 [· #author-text(by)] #if info.subtitle != none [#emph(info.subtitle)] #if info.description != none [#info.description] ] } html.elem("article", attrs: (class: "content-box post-card"))[ #html.h2(class: "post-card-title", html.a(href: info.href, title)) #if info.subtitle != none { html.p(class: "post-card-subtitle", info.subtitle) } #if info.date != none or by.len() > 0 { html.p(class: "post-card-meta")[ #if info.date != none { html.elem("time", attrs: (datetime: date-key(info)), format-date(info.date)) } #if info.date != none and by.len() > 0 [ · ] #if by.len() > 0 [#author-text(by)] ] } #if info.description != none { html.p(class: "post-card-description", info.description) } #if info.pdf { html.p(class: "post-card-links")[ #html.a(href: "/" + info.pdf-path)[View as PDF] ] } ] }