#import "data/config.typ": *
#import "data/theme.typ": *
#import "data/glossary.typ": init-glossary, print-glossary-block, register-report-glossary, gls-long, gls-short
#import "data/diagrams.typ": ore-sorting-flow
#import "data/code.typ": codly-init-rule, codly-config, code-token-highlight-init
#import "data/styling.typ": apply-report-styling
#import "data/layout.typ": cover-block, summary-block, page-header, page-footer, page-accent-bar
#import "data/md.typ": load-report-md

#show: codly-init-rule
#show: code-token-highlight-init
#show: init-glossary
#codly-config

#register-report-glossary()

#let report = load-report-md(
  read(content-path),
  source-path: content-path,
  extra-scope: (
    ore-sorting-flow: ore-sorting-flow,
    gls-long: gls-long,
    gls-short: gls-short,
  ),
)
#let meta = report.metadata

#set page(
  paper: "a4",
  margin: page-margin,
  header-ascent: page-header-ascent,
  footer-descent: page-footer-descent,
  fill: color-page,
  background: page-accent-bar(),
  header: context {
    if counter(page).get().first() > 1 {
      page-header(meta)
    }
  },
  footer: context {
    if counter(page).get().first() > 1 {
      page-footer()
    }
  },
)

#set text(font: body-font, lang: "zh", size: size-body, fill: color-body)
#set par(leading: leading-body, justify: true)

#cover-block(meta)
#summary-block(meta)
#apply-report-styling(report.body)
#print-glossary-block()
