diff --git a/README.md b/README.md index 3366def..9ed52a6 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +## \*\*\*\*_This repo is no longer being maintained_\*\*\*\* +_Vermilion Design has shifted the way that we develop for Gutenberg which means that this repo will no longer be relevant for our workflow. Additionally, there is a fundamental flaw with getting posts the way that this component does it. Data will not change when the source posts are updated. In order to circumvent this, you should use Server Side Rendering views, which are much easier to write and maintain. However, if you would like to still use this component, you should check out one of the forks._ + # Gutenberg PostSelector REQUIRES WordPress 5.0+ @@ -46,8 +49,8 @@ registerBlockType('vermilion/post-selector', { { - attributes.posts.push(post); - setAttributes({ posts: [...attributes.posts] }); + const updatedPosts = [...attributes.posts, post]; + setAttributes({ posts: updatedPosts }); }} posts={attributes.posts} onChange={newValue => { diff --git a/src/PostSelector.js b/src/PostSelector.js index 1e849ca..4248820 100644 --- a/src/PostSelector.js +++ b/src/PostSelector.js @@ -202,11 +202,11 @@ class PostSelector extends Component { apiFetch({ path: `/wp/v2/${restBase}/${post.id}` }).then(response => { - // console.log( response ); + const excerpt = response.excerpt ? response.excerpt.rendered : ''; const fullpost = { title: decodeEntities(response.title.rendered), id: response.id, - excerpt: decodeEntities(response.excerpt.rendered), + excerpt: decodeEntities(excerpt), url: response.link, date: response.date, type: response.type,