summaryrefslogtreecommitdiffstats
path: root/lib/api/encodePage.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/api/encodePage.js')
-rw-r--r--lib/api/encodePage.js20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/api/encodePage.js b/lib/api/encodePage.js
index 9ec55bc..98d7409 100644
--- a/lib/api/encodePage.js
+++ b/lib/api/encodePage.js
@@ -1,3 +1,5 @@
+var JSONUtils = require('../json');
+var deprecate = require('./deprecate');
/**
Encode a page in a context to a JS API
@@ -7,8 +9,26 @@
@return {Object}
*/
function encodePage(output, page) {
+ var book = output.getBook();
+ var summary = book.getSummary();
+ var fs = book.getContentFS();
+ var file = page.getFile();
+ // JS Page is based on the JSON output
+ var result = JSONUtils.encodePage(page, summary);
+ result.type = file.getType();
+ result.path = file.getPath();
+ result.rawPath = fs.resolve(result.path);
+
+ deprecate.field(output, 'page.section', result, 'sections', [
+ {
+ content: result.content,
+ type: 'normal'
+ }
+ ], '"sections" property is deprecated, use page.content instead');
+
+ return result;
}
module.exports = encodePage;