Context API

Starting with KduPress 1.x.x, KduPress provides an AppContext object that stores all the state of the current app and can be accessed through the plugin API.

Note

Context of each plugin is a isolated context inherited from the same app context.

module.exports = (options, ctx) => {
  // ...
}

ctx.isProd

  • Type: boolean

Whether KduPress run in production environment mode.

ctx.pages

  • Type: array

Contains a list of Page objects

ctx.sourceDir

  • Type: string

Root directory where the documents are located.

ctx.tempPath

  • Type: string

Root directory where the temporary files are located.

ctx.outDir

  • Type: string

Output path.

ctx.base

  • Type: string

See: base.

ctx.writeTemp

  • Type: Function

A utility for writing temporary files to tempPath.