-
-
Notifications
You must be signed in to change notification settings - Fork 373
/
Copy pathCreateMarkdownPage.js
67 lines (62 loc) · 1.78 KB
/
CreateMarkdownPage.js
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import React from 'react';
import PropTypes from 'prop-types';
import { HotKeys } from 'react-hotkeys';
import Button from './Button';
import Errors from './Errors';
import Breadcrumbs from './Breadcrumbs';
import MarkdownPageBody from './MarkdownPageBody';
import { injectDefaultFields as defaultFields } from '../utils/metadata';
export default function CreateMarkdownPage({
type,
config,
errors,
updated,
updateBody,
updatePath,
updateTitle,
fieldChanged,
onClickSave,
params: { splat },
}) {
const metaType = type === 'drafts' ? 'posts' : type;
return (
<HotKeys handlers={{ save: onClickSave }}>
{errors.length > 0 && <Errors errors={errors} />}
<div className="content-header">
<Breadcrumbs type={type} splat={splat} />
</div>
<div className="content-wrapper">
<MarkdownPageBody
type={type}
config={config}
updatePath={updatePath}
updateTitle={updateTitle}
updateBody={updateBody}
onSave={onClickSave}
staticmetafields={defaultFields(config, splat, metaType)}
/>
<div className="content-side">
<Button
onClick={onClickSave}
type="create"
active={fieldChanged}
triggered={updated}
block
/>
</div>
</div>
</HotKeys>
);
}
CreateMarkdownPage.propTypes = {
type: PropTypes.string.isRequired,
config: PropTypes.object.isRequired,
params: PropTypes.object.isRequired,
errors: PropTypes.array.isRequired,
updated: PropTypes.bool.isRequired,
fieldChanged: PropTypes.bool.isRequired,
updateBody: PropTypes.func.isRequired,
updatePath: PropTypes.func.isRequired,
updateTitle: PropTypes.func.isRequired,
onClickSave: PropTypes.func.isRequired,
};