summaryrefslogtreecommitdiffstats
path: root/lib/parse/parsePageFromString.js
blob: 80c147bb84b6d79c4b5cce370f2fcbe918aae344 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
var Immutable = require('immutable');
var fm = require('front-matter');
var direction = require('direction');

/**
 * Parse a page, its content and the YAMl header
 *
 * @param {Page} page
 * @return {Page}
 */
function parsePageFromString(page, content) {
    var parsed = fm(content);

    return page.merge({
        content:    parsed.body,
        attributes: Immutable.fromJS(parsed.attributes),
        dir:        direction(parsed.body)
    });
}


module.exports = parsePageFromString;