diff options
Diffstat (limited to 'packages/gitbook/src/api/decodeGlobal.js')
-rw-r--r-- | packages/gitbook/src/api/decodeGlobal.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/gitbook/src/api/decodeGlobal.js b/packages/gitbook/src/api/decodeGlobal.js new file mode 100644 index 0000000..c7bbcc7 --- /dev/null +++ b/packages/gitbook/src/api/decodeGlobal.js @@ -0,0 +1,22 @@ +const decodeConfig = require('./decodeConfig'); + +/** + * Decode changes from a JS API to a output object. + * Only the configuration can be edited by plugin's hooks + * + * @param {Output} output + * @param {Object} result: result from API + * @return {Output} output + */ +function decodeGlobal(output, result) { + let book = output.getBook(); + let config = book.getConfig(); + + // Update config + config = decodeConfig(config, result.config); + book = book.set('config', config); + + return output.set('book', book); +} + +module.exports = decodeGlobal; |