summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/models/Page.js
blob: e3c4a96cda147eeb88a3500f79b4ecef5d7f55df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
const { Record, Map, fromJS } = require('immutable');

const DEFAULTS = {
    title:      '',
    content:    '',
    dir:        'ltr',
    depth:      1,
    level:      '',
    previous:   null,
    next:       null,
    attributes: Map()
};

class Page extends Record(DEFAULTS) {
    static create(state) {
        return state instanceof Page ?
            state : new Page({
                ...state,
                attributes: fromJS(state.attributes)
            });
    }
}

module.exports = Page;