charge

Types

pub opaque type Asset
pub type HTMLFile {
  HTMLFile(
    source: option.Option(fs.Path),
    path: fs.SitePath,
    html: element.ElementTree,
  )
}

Constructors

pub opaque type Loaded(page, aggregate)

load -> process -> persist

pub opaque type Pipeline(state, aggregate)
pub type Rendered =
  List(Asset)

Values

pub fn asset_to_readable_string(asset: Asset) -> String
pub fn assets_to_readable_string(assets: List(Asset)) -> String
pub fn derived_html_file(
  source: fs.Path,
  path: fs.SitePath,
  rendered: element.ElementTree,
) -> Asset
pub fn find_asset(
  assets: List(Asset),
  path: fs.SitePath,
) -> Result(Asset, Nil)
pub fn generated_html_file(
  path: fs.SitePath,
  rendered: element.ElementTree,
) -> Asset
pub fn if_html(
  asset: Asset,
  or_else: a,
  f: fn(HTMLFile) -> a,
) -> a
pub fn loaded(
  pages pages: List(page),
  aggregate aggregate: aggregate,
) -> Loaded(page, aggregate)
pub fn new(
  out out_dir: fs.Path,
  load load: fn() -> Result(
    Loaded(state, aggregate),
    error.ChargeError,
  ),
  render render: fn(List(state), aggregate) -> Result(
    List(Asset),
    error.ChargeError,
  ),
) -> Pipeline(state, aggregate)
pub fn run(
  pipeline: Pipeline(page, aggregate),
) -> promise.Promise(Result(List(Asset), error.ChargeError))

Cleans the output directory and runs the pipeline

pub fn sort_assets(assets: List(Asset)) -> List(Asset)
pub fn text_file(path: fs.SitePath, content: String) -> Asset
pub fn with(
  from: Pipeline(page, aggregate),
  render: fn(aggregate) -> Result(List(Asset), error.ChargeError),
) -> Pipeline(page, aggregate)
pub fn with_asset(
  from: Pipeline(page, aggregate),
  render: fn(aggregate) -> Result(Asset, error.ChargeError),
) -> Pipeline(page, aggregate)

Derive an asset from the pipeline aggregate

pub fn with_assets(
  from: Pipeline(page, aggregate),
  render: fn(aggregate) -> Result(List(Asset), error.ChargeError),
) -> Pipeline(page, aggregate)

Derive some assets from the pipeline aggregate

pub fn with_async(
  from: Pipeline(page, aggregate),
  render: fn(aggregate) -> promise.Promise(
    Result(List(Asset), error.ChargeError),
  ),
) -> Pipeline(page, aggregate)

The raw unit for composing sync rendering pipelines

pub fn with_async_component(
  from: Pipeline(state, aggregate),
  comp: #(
    String,
    fn(component.RenderData, element.ElementTree) -> promise.Promise(
      Result(element.ElementTree, error.ChargeError),
    ),
  ),
) -> Pipeline(state, aggregate)
pub fn with_components(
  from: Pipeline(page, aggregate),
  comps: List(
    #(
      String,
      fn(component.RenderData, element.ElementTree) -> Result(
        element.ElementTree,
        error.ChargeError,
      ),
    ),
  ),
) -> Pipeline(page, aggregate)

Add server-side components to the pipeline

pub fn with_derived_assets(
  from: Pipeline(page, aggregate),
  extract: fn(Asset) -> Result(List(Asset), error.ChargeError),
) -> Pipeline(page, aggregate)

Add assets that are derived from an existing asset, e.g. providing an alternate of each page

pub fn with_static_dir(
  pipeline: Pipeline(page, aggregate),
  dir: fs.Path,
) -> Pipeline(page, aggregate)

Add a static directory to be copied as part of the pipeline

pub fn with_summary(
  from: Pipeline(state, aggregate),
  summarize: fn(List(Asset), aggregate) -> Result(
    List(Asset),
    error.ChargeError,
  ),
) -> Pipeline(state, aggregate)

Add some generic tasks into the pipeline given all the assets rendered till this point as well as the relevant aggregate e.g. running creating an accessibility report on all generated html pages, creating an RSS Feed, etc.

Search Document