Add block to extract embeds from post content in query loops #26
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
When using region-based client side navigation in query loops, we are prohibited from using the post content block in post templates (see video below).
However, this block allows us to partly circumvent that limitation. One of the designs on the Mike Flanagan site requires displaying an embed from the post content inside of the query loop on an archive page — and this PR allows us to do that without rendering the post content directly.
Why
Video archive pages should have a way to render videos in a query loop while using client side navigation.
How
This dynamic block reads the embed information from post content while generating the markup for an embed block in the
render_callback
method, both on the frontend and in the editor. To do this, it borrows heavily from thecore/embed
block.How to Test
1. Post Setup
a. Create a post.
b. Add a YouTube embed.
c. Add some additional content.
d. Save the post.
2. Extract Embed from Post
a. In the Site Editor, add or use a query loop that will query the post from step 1. Make sure the post template does not contain a content block.
b. Inside of the query loop's post template, add the Client Side Extract Embed block.
c. See that the YouTube embed from the post content renders.
d. Save and view the template — ensure that only the YouTube embed shows and not the rest of the post's content.
Walkthrough video
https://cldup.com/AzVIYLnhzH.mp4