diff options
Diffstat (limited to 'packages/gitbook/src/api/decodePage.js')
-rw-r--r-- | packages/gitbook/src/api/decodePage.js | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/packages/gitbook/src/api/decodePage.js b/packages/gitbook/src/api/decodePage.js index 4fd78af..395c8ff 100644 --- a/packages/gitbook/src/api/decodePage.js +++ b/packages/gitbook/src/api/decodePage.js @@ -1,14 +1,14 @@ -const deprecate = require('./deprecate'); +const Immutable = require('immutable'); /** - Decode changes from a JS API to a page object. - Only the content can be edited by plugin's hooks. - - @param {Output} output - @param {Page} page: page instance to edit - @param {Object} result: result from API - @return {Page} -*/ + * Decode changes from a JS API to a page object. + * Only the content can be edited by plugin's hooks. + * + * @param {Output} output + * @param {Page} page: page instance to edit + * @param {Object} result: result from API + * @return {Page} + */ function decodePage(output, page, result) { const originalContent = page.getContent(); @@ -18,7 +18,9 @@ function decodePage(output, page, result) { return page; } - deprecate.disable('page.sections'); + // Update page attributes + const newAttributes = Immutable.fromJS(page.attributes); + page = page.set('attributes', newAttributes); // GitBook 3 // Use returned page.content if different from original content @@ -26,18 +28,6 @@ function decodePage(output, page, result) { page = page.set('content', result.content); } - // GitBook 2 compatibility - // Finally, use page.sections - else if (result.sections) { - page = page.set('content', - result.sections.map(function(section) { - return section.content; - }).join('\n') - ); - } - - deprecate.enable('page.sections'); - return page; } |