Skip to content
javarome edited this page May 21, 2024 · 3 revisions

Ssg is Static Site Generation API main class, which is responsible for executing Steps.

Typical usage of Ssg is:

  1. create a new instance with a SsgConfig (which consist basically in a {outDir: string})
  2. add Steps to it (mind the order)
  3. start the generation with a Context

For instance:

import {SsgConfig, SsgContextImpl, Ssg, ContentStep, CopyStep} from "ssg-api"

const config: SsgConfig = {
  getOutputPath(context: SsgContext): string {
    return path.join("out", context.file.name)
  }
}
const context = new SsgContextImpl("fr")

new Ssg(config)
  .add(new ContentStep(contentConfigs, outputFunc))
  .add(dir1SubdirectoriesStep)
  .add(dir2SubdirectoriesStep)
  .add(...anArrayOfSteps)
  .add(new CopyStep(copiesToDo))
  .start(context)
Clone this wiki locally