summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-core/src/models/Config.js
blob: 50abef2ca69f47acaf8874783b45ebd8131b4624 (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
const { Map, fromJS } = require('immutable');

/**
 * Configuration from the book.
 * @type {Class}
 */
class Config extends Map {

    /**
     * Create a config instance from values.
     * @param  {Mixed} values
     * @return {Config}
     */
    static create(values) {
        return values instanceof Config ?
            values : new Config(fromJS(values));
    }

    /**
     * Get configuration for a plugin.
     * @param  {String} pluginName
     * @return {Map}
     */
    getForPlugin(pluginName) {
        return this.getIn([
            'pluginsConfig', pluginName
        ]);
    }

}

module.exports = Config;