summaryrefslogtreecommitdiffstats
path: root/packages/gitbook/src/models/readme.js
blob: 0fb52b4e1e35ced13b61582ee68429c0ac38bc76 (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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
const Immutable = require('immutable');

const File = require('./file');

const Readme = Immutable.Record({
    file:           File(),
    title:          String(),
    description:    String()
});

Readme.prototype.getFile = function() {
    return this.get('file');
};

Readme.prototype.getTitle = function() {
    return this.get('title');
};

Readme.prototype.getDescription = function() {
    return this.get('description');
};

/**
    Create a new readme

    @param {File} file
    @param {Object} def
    @return {Readme}
*/
Readme.create = function(file, def) {
    def = def || {};

    return new Readme({
        file,
        title: def.title || '',
        description: def.description || ''
    });
};

module.exports = Readme;