Skip to content

Commit

Permalink
Post Title Block: Sync value with post slug.
Browse files Browse the repository at this point in the history
  • Loading branch information
epiqueras committed Jul 14, 2019
1 parent f2abe6f commit 07392e0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/block-library/src/post-title/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
"type": "string",
"source": "post",
"attribute": "title"
},
"slug": {
"type": "string",
"source": "post",
"attribute": "slug"
}
}
}
7 changes: 2 additions & 5 deletions packages/block-library/src/post-title/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
* WordPress dependencies
*/
import { __ } from '@wordpress/i18n';

/**
* WordPress dependencies
*/
import { cleanForSlug } from '@wordpress/editor';
import { RichText } from '@wordpress/block-editor';

export default function PostTitleEdit( {
Expand All @@ -15,7 +12,7 @@ export default function PostTitleEdit( {
return (
<RichText
value={ title }
onChange={ ( value ) => setAttributes( { title: value } ) }
onChange={ ( value ) => setAttributes( { title: value, slug: cleanForSlug( value ) } ) }
tagName="h1"
placeholder={ __( 'Title' ) }
formattingControls={ [] }
Expand Down

0 comments on commit 07392e0

Please sign in to comment.