Gutenberg: Add a Jetpack Related Posts block#26530
Conversation
193d110 to
d11976e
Compare
|
I see related posts! I had to remove |
|
Oops, test instructions haven't been updated in a while 😉 The ones in #27126 would work better these days. |
|
How can we test this? Do you want @mapk and I to test this? I'm not aware of any prior designs for this feature. Is this just largely a test/learning PR? |
| date: 'August 5, 2018', | ||
| context: 'In "Upgrade"', | ||
| }, | ||
| ]; |
There was a problem hiding this comment.
These example texts and images are straight from the current version in Jetpack — since we're at it, we should probably look up some more fresh demo content. Won't stop merging though, just noting down.
There was a problem hiding this comment.
Good point 👍
However, I'll defer that decision to @MichaelArestad and @mapk - I'm not planning any changes, as that would affect other bits that already use this content.
Also, FWIW, if we decide to change the content, we should do in all instances - both Jetpack (the plugin) and Calypso (site settings).
There was a problem hiding this comment.
I take it that if we plan to pull in actual site content even in editor mode (in a subsequent iteration), we'll be able to drop the demo content?
| import edit from './edit'; | ||
| import { MAX_POSTS_TO_SHOW } from './constants'; | ||
|
|
||
| registerBlockType( 'jetpack/related-posts', { |
There was a problem hiding this comment.
Considering this will be used elsewhere than just Jetpack, should we stick to a8c namespace?
There was a problem hiding this comment.
Yup, I agree.
Done in dcef260.
We can always change it back if we reconsider for any reason (like grouping blocks under the same category/group in the block inserter).
| <Toolbar controls={ layoutControls } /> | ||
| </BlockControls> | ||
|
|
||
| <div className="related-posts__main"> |
There was a problem hiding this comment.
Should we rely on generated className prop here? Both edit and save have className prop available and it should be wp-block-a8c-related-posts (or wp-block-jetpack-related-posts) for this block.
https://wordpress.org/gutenberg/handbook/block-api/block-edit-save/#classname
There was a problem hiding this comment.
Good point 👍
I think the generated className weren't there yet when I started working on this block 😉
I've updated the block to use that class and cleaned up any unnecessary instances in b9e6a6e
There aren't any designs as far as I know.
It started as an exploration to help showcase how the SDK can be used to build a block from scratch, but eventually turned out to work pretty well, so we can actually use it for building the production block.
Thanks, I'd love to get that tested; let me take some time to prepare the PR and a playground and I'll ping you folks. |
|
This is now ready for review and testing ✅ |
|
@tyxla Can we see a recorded video of how this works posted in this thread? At least until we can get a more simplified testing environment going? |
| ]; | ||
|
|
||
| const displayPosts = | ||
| DEFAULT_POSTS.length > postsToShow ? DEFAULT_POSTS.slice( 0, postsToShow ) : DEFAULT_POSTS; |
There was a problem hiding this comment.
Fun fact! This should be equivalent to the inner case…
const displayPosts = DEFAULT_POSTS.slice( 0, postToShow );the only difference is that we are cloning the array each time and as-written we're not cloning when the array is empty. since this is inside a render() function it won't trigger additional re-renders
unless there's a reason to leave it here we should be able to remove the conditional altogether.
5cea80a to
5d766d3
Compare
|
@mapk thanks for the great feedback, I've been working today on addressing it - see my comments below; also I'd appreciate reviews and feedback on the proposed solutions.
I've suggested that in #27451. It's worth to mention that @mtias suggested that we use something unique - what can we do to make the icon similar, but still unique?
Well, I'm planning to work on getting real-time content working, but it seems it'll be after the GM. Also, it's not clear whether we'll be able to ship it in the v1, considering the fact that it would require a premium plan feature (Jetpack Search). So I'd really appreciate if you have suggestions for some better images and text - I'd love to implement them.
Nice - I've suggested that in #27456.
Okay, that's fair enough. I've opted for removing the headline bit in #27454.
Sounds good, let's skip categories/tags for the v1 👍 |
Description
This PR introduces a Jetpack Related Posts block for Gutenberg, written entirely in Calypso, intended to be built with the Calypso SDK.
Preview
Grid view with block controls, no alignment specified

List view with block controls, no alignment specified

Grid view with block controls, center alignment specified

Grid view with block controls, wide alignment specified

Grid view with block controls, full-width alignment specified

Inspector controls

Testing
Short instructions (no local dev env setup necessary)
Long instructions (local dev env setup necessary)
add_filter( 'jetpack_gutenberg', '__return_true', 10 );add_filter( 'jetpack_gutenberg_cdn', '__return_false', 10 );PATH_TO_JETPACKis the path to your Jetpack repo) to build the Jetpack preset of blocks: