@@ -12,23 +12,30 @@ export default class Breadcrumbs extends Component {
1212 }
1313
1414 render ( ) {
15- const { link, type, path } = this . props ;
16- let placeholder = 'example.md' ;
15+ const { link, type, content, editable } = this . props ;
1716
18- if ( type == 'posts' ) {
19- const date = moment ( ) . format ( 'YYYY-MM-DD' ) ;
20- placeholder = `${ date } -your-title.md` ;
21- } else if ( type == 'data files' ) {
22- placeholder = 'your-filename.yml' ;
17+ let node = null ;
18+ if ( editable ) {
19+ let placeholder = 'example.md' ;
20+ if ( type == 'posts' ) {
21+ const date = moment ( ) . format ( 'YYYY-MM-DD' ) ;
22+ placeholder = `${ date } -your-title.md` ;
23+ } else if ( type == 'datafiles' ) {
24+ placeholder = 'your-filename.yml' ;
25+ }
26+ node = ( < input onChange = { ( e ) => this . handleChange ( e ) }
27+ placeholder = { placeholder }
28+ defaultValue = { content }
29+ ref = "input" /> ) ;
30+ } else {
31+ node = content ;
2332 }
33+
2434 return (
2535 < ul className = "breadcrumbs" >
2636 < li > < Link to = { link } > { toTitleCase ( type ) } </ Link > </ li >
2737 < li className = "filename" >
28- < input onChange = { ( e ) => this . handleChange ( e ) }
29- ref = "input"
30- placeholder = { placeholder }
31- defaultValue = { path } />
38+ { node }
3239 </ li >
3340 </ ul >
3441 ) ;
@@ -38,6 +45,7 @@ export default class Breadcrumbs extends Component {
3845Breadcrumbs . propTypes = {
3946 link : PropTypes . string . isRequired ,
4047 type : PropTypes . string . isRequired ,
41- path : PropTypes . string . isRequired ,
42- onChange : PropTypes . func . isRequired
48+ content : PropTypes . string . isRequired ,
49+ editable : PropTypes . bool ,
50+ onChange : PropTypes . func
4351} ;
0 commit comments