From 53cfa3703b0ab9756dd773fb5fe7de2b9cbf0085 Mon Sep 17 00:00:00 2001 From: Johan Preynat Date: Wed, 13 Apr 2016 09:33:26 +0200 Subject: [PATCH] Update page context for plugins hooks --- lib/page/index.js | 1 - lib/plugins/compatibility.js | 13 +++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/page/index.js b/lib/page/index.js index bcd83e6d5..f0d7f57fb 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -7,7 +7,6 @@ var error = require('../utils/error'); var pathUtil = require('../utils/path'); var location = require('../utils/location'); var parsers = require('../parsers'); -var gitbook = require('../gitbook'); var pluginCompatibility = require('../plugins/compatibility'); var HTMLPipeline = require('./html'); diff --git a/lib/plugins/compatibility.js b/lib/plugins/compatibility.js index 9f80c38a1..eb64e4885 100644 --- a/lib/plugins/compatibility.js +++ b/lib/plugins/compatibility.js @@ -14,12 +14,13 @@ function pluginCtx(plugin) { // Call a function "fn" with a context of page similar to the one in GitBook v2 function pageHook(page, fn) { - var ctx = { - type: page.type, - content: page.content, - path: page.path, - rawPath: page.rawPath - }; + // Get page context + var ctx = page.getContext().page; + + // Add other informations + ctx.type = page.type; + ctx.rawPath = page.rawPath; + ctx.path = page.path; // Deprecate sections error.deprecateField(ctx, 'sections', [