summaryrefslogtreecommitdiffstats
path: root/lib/parse/parsePage.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-04-23 17:10:16 +0200
committerSamy Pesse <samypesse@gmail.com>2016-04-23 17:10:16 +0200
commite1fa977b5b1b3c03790de6e2c21ee39ba55d9555 (patch)
treea1ad4386100b5779ef930845093c14639a3353b5 /lib/parse/parsePage.js
parentce95f316b9ce1eac1e615db3540c4d0f30408d63 (diff)
downloadgitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.zip
gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.tar.gz
gitbook-e1fa977b5b1b3c03790de6e2c21ee39ba55d9555.tar.bz2
Add json encoding utils
Diffstat (limited to 'lib/parse/parsePage.js')
-rw-r--r--lib/parse/parsePage.js11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/parse/parsePage.js b/lib/parse/parsePage.js
index 75bcf61..1d515d6 100644
--- a/lib/parse/parsePage.js
+++ b/lib/parse/parsePage.js
@@ -1,4 +1,6 @@
+var Immutable = require('immutable');
var fm = require('front-matter');
+var direction = require('direction');
/**
Parse a page, read its content and parse the YAMl header
@@ -15,10 +17,11 @@ function parsePage(book, page) {
.then(function(content) {
var parsed = fm(content);
- page = page.set('content', parsed.body);
- page = page.set('attributes', parsed.attributes);
-
- return page;
+ return page.merge({
+ content: parsed.body,
+ attributes: Immutable.fromJS(parsed.attributes),
+ dir: direction(parsed.body)
+ });
});
}