summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-search/src/models/Result.js
blob: 0012b2b049b4083f7ead00278de1c14da5a9864f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const GitBook = require('gitbook-core');
const { Record } = GitBook.Immutable;

const DEFAULTS = {
    url:   String(''),
    title: String(''),
    body:  String('')
};

class Result extends Record(DEFAULTS) {
    constructor(spec) {
        if (!spec.url || !spec.title) {
            throw new Error('"url" and "title" are required to create a search result');
        }

        super(spec);
    }
}

module.exports = Result;