Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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+
Expand Down Expand Up @@ -46,8 +49,8 @@ registerBlockType('vermilion/post-selector', {

<PostSelector
onPostSelect={post => {
attributes.posts.push(post);
setAttributes({ posts: [...attributes.posts] });
const updatedPosts = [...attributes.posts, post];
setAttributes({ posts: updatedPosts });
}}
posts={attributes.posts}
onChange={newValue => {
Expand Down
4 changes: 2 additions & 2 deletions src/PostSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down