Files
gitbook/lib/plugins/context.js
T
2016-02-22 15:34:35 +01:00

28 lines
661 B
JavaScript

var error = require('../utils/error');
/*
Return the context for a plugin.
It tries to keep compatibilities with GitBook v2
*/
function pluginCtx(plugin) {
var book = plugin.book;
var ctx = {
config: book.config,
log: plugin.log,
// Paths
resolve: book.resolve
};
// Deprecation
error.deprecateField(ctx, 'options', book.config.dump(), '"options" property is deprecated, use config.get(key) instead');
// Loop for template filters/blocks
error.deprecateField(ctx, 'book', ctx, '"book" property is deprecated, use "this" directly instead');
return ctx;
}
module.exports = pluginCtx;