@@ -15,6 +15,7 @@ import Metadata from '../MetaFields';
15
15
import { fetchPage , deletePage , putPage } from '../../actions/pages' ;
16
16
import { updateTitle , updateBody , updatePath } from '../../actions/metadata' ;
17
17
import { clearErrors } from '../../actions/utils' ;
18
+ import { injectDefaultFields } from '../../utils/metadata' ;
18
19
import { preventDefault } from '../../utils/helpers' ;
19
20
import {
20
21
getLeaveMessage , getDeleteMessage , getNotFoundMessage
@@ -89,7 +90,7 @@ export class PageEdit extends Component {
89
90
90
91
render ( ) {
91
92
const { isFetching, page, errors, updateTitle, updateBody, updatePath,
92
- updated, fieldChanged, params } = this . props ;
93
+ updated, fieldChanged, params, config } = this . props ;
93
94
94
95
if ( isFetching ) {
95
96
return null ;
@@ -105,7 +106,10 @@ export class PageEdit extends Component {
105
106
106
107
const { name, raw_content, http_url, path, front_matter } = page ;
107
108
const [ directory , ...rest ] = params . splat ;
109
+
108
110
const title = front_matter && front_matter . title ? front_matter . title : '' ;
111
+ const metafields = injectDefaultFields ( config , directory , 'pages' , front_matter ) ;
112
+
109
113
return (
110
114
< HotKeys
111
115
handlers = { keyboardHandlers }
@@ -126,7 +130,7 @@ export class PageEdit extends Component {
126
130
initialValue = { raw_content }
127
131
ref = "editor" />
128
132
< Splitter />
129
- < Metadata fields = { { title, raw_content, path : name , ...front_matter } } />
133
+ < Metadata fields = { { title, raw_content, path : name , ...metafields } } />
130
134
</ div >
131
135
132
136
< div className = "content-side" >
@@ -173,15 +177,17 @@ PageEdit.propTypes = {
173
177
updated : PropTypes . bool . isRequired ,
174
178
params : PropTypes . object . isRequired ,
175
179
router : PropTypes . object . isRequired ,
176
- route : PropTypes . object . isRequired
180
+ route : PropTypes . object . isRequired ,
181
+ config : PropTypes . object . isRequired
177
182
} ;
178
183
179
184
const mapStateToProps = ( state ) => ( {
180
185
page : state . pages . page ,
181
186
isFetching : state . pages . isFetching ,
182
187
fieldChanged : state . metadata . fieldChanged ,
183
188
updated : state . pages . updated ,
184
- errors : state . utils . errors
189
+ errors : state . utils . errors ,
190
+ config : state . config . config
185
191
} ) ;
186
192
187
193
const mapDispatchToProps = ( dispatch ) => bindActionCreators ( {
0 commit comments