#import "./html_head.typ": html_head
#import "./html_body.typ": html_body
#import "./html_utils.typ": html_show
#import "./summary.typ": summary, card-list


/// Mail template function
#let webpage(
  /// Page url
  url: none,
  /// Title of the page, default to document.title
  title: none,
  /// Use only for html 'lang' attribute.
  lang: "en",
  //-- <head> only args --
  /// Website icon, *needs* to be path (TODO: fix when typst support multi-file out)
  icon: none,
  /// Type of the page for open-graph data
  og-type: "website",
  /// Name of the site for metadata of the page
  site-name: none,
  /// Description of the site for metadata, default to document.description
  description: none,
  /// Author of the site for metadata, default to document.author
  author: none,
  /// Additional stylesheet for the page: must be a list of url
  stylesheets: (),
  /// List of related sites for metadata
  me-links: (),
  //-- Body --
  /// Home button, more or less expect an image in a link
  home: none,
  /// Navigation menu content, css style expect a list of links, but it can
  /// be anything
  menu: none,
  /// Logo in page header
  logo: none,
  /// Page header
  header: none,
  /// Page footer
  footer: none,
  /// Body of the page
  body
) = {
  assert(type(url) == str, message: "A page must have an url")
  show: html_show
  html.html(lang: lang, {
    html_head(
      url,
      title,
      icon: icon,
      og-type: og-type,
      site-name: site-name,
      description: description,
      author: author,
      stylesheets: stylesheets,
      me-links: me-links
    )
    html_body(
      home: home,
      logo: logo,
      header: header,
      footer: footer,
      menu: menu,
      body
    )
  })
}
