Skip to content

Latest commit

History

History
55 lines (31 loc) 路 873 Bytes

context-api.md

File metadata and controls

55 lines (31 loc) 路 873 Bytes

Context API

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

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

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

ctx.isProd

  • Type: boolean

Whether VuePress 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.