summaryrefslogtreecommitdiffstats
path: root/packages/gitbook-plugin-theme-default/src/index.js
blob: 4b98a2280c3edabe7783cac7bdf2396bd75afc61 (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
const React = require('react');
const GitBook = require('gitbook-core');

const Sidebar = require('./Sidebar');
const Page = require('./Page');
const Toolbar = require('./Toolbar');

let ThemeBody = React.createClass({
    propTypes: {
        page:     GitBook.Shapes.Page,
        children: React.PropTypes.node
    },

    render() {
        const { page, children } = this.props;

        return (
            <div className="GitBook book">
                <GitBook.Head
                    title={page.title}
                    titleTemplate="%s - GitBook" />
                <GitBook.ImportCSS href="gitbook/gitbook-plugin-theme-default/theme.css" />

                <Toolbar />
                <Sidebar />
                <Page page={page} />
                {children}
            </div>
        );
    }
});

ThemeBody = GitBook.connect(ThemeBody, ({page}) => {
    return { page };
});

module.exports = GitBook.createPlugin((dispatch, state) => {
    dispatch(GitBook.registerComponent(ThemeBody, { role: 'Body' }));
});