Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable related posts for AMP #13028

Merged
merged 6 commits into from
Jul 29, 2019
Merged

Enable related posts for AMP #13028

merged 6 commits into from
Jul 29, 2019

Conversation

gravityrail
Copy link
Contributor

@gravityrail gravityrail commented Jul 11, 2019

Fixes #9556

Currently the related posts block is disabled for all AMP requests because they don't support client-side JS. However, the Gutenberg block does server side rendering. This patch reuses the Gutenberg code in kind of a brute-force way to enable Related Posts in AMP.

cc @westonruter @jeffersonrabb

Changes proposed in this Pull Request:

  • Enable Related Posts for AMP pages

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • This adds Related Posts support to AMP pages

Testing instructions:

  • Install and activate the AMP plugin (tested with v1.2)
  • Enable Related posts
  • View the AMP version of a page by appending ?amp
  • Related posts should be displayed
  • Try changing some settings (e.g. enable/disable thumbnails, enable/disable heading). Should work similarly to front-end

This is the most minimal, brute-force version I could create. It may create invalid AMP in other ways (e.g. too much CSS). Comments and corrections welcome.

Proposed changelog entry for your changes:

  • Enable Related Posts for AMP pages

@gravityrail gravityrail requested a review from a team July 11, 2019 05:05
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello gravityrail! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D30356-code before merging this PR. Thank you!

@gravityrail gravityrail added AMP [Feature] Related Posts [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 11, 2019
@jetpackbot
Copy link

jetpackbot commented Jul 11, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: August 6, 2019.
Scheduled code freeze: July 30, 2019

Generated by 🚫 dangerJS against 6725d38

@gravityrail gravityrail added this to the 7.6 milestone Jul 11, 2019
@matticbot
Copy link
Contributor

gravityrail, Your synced wpcom patch D30356-code has been updated.

@matticbot
Copy link
Contributor

gravityrail, Your synced wpcom patch D30356-code has been updated.

@westonruter
Copy link
Contributor

westonruter commented Jul 11, 2019

I enabled:

image

Rendering as:

image

When thumbnails are hidden:

image

With heading hidden (with social sharing icons included above to show spacing):

image

Here's the https://dev-westonruter.pantheonsite.io/2019/03/21/using-the-amp-plugin-to-protect-site-visitors-and-debug-security-vulnerabilities/

It looks good, except for the thumbnails being a bit off.

@westonruter
Copy link
Contributor

In Reader mode there is no styling, so either the styling needs to be added or the Related Posts should be omitted if ! current_theme_supports( 'amp' ):

image

@westonruter
Copy link
Contributor

It looks good, except for the thumbnails being a bit off.

It's not the thumbnail, it's the text link under the thumbnail, where there is a styling problem:

image

@matticbot
Copy link
Contributor

gravityrail, Your synced wpcom patch D30356-code has been updated.

@jeherve jeherve removed this from the 7.6 milestone Jul 25, 2019
Copy link
Contributor

@jeffersonrabb jeffersonrabb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good - only change needed is the $enqueue_script logic.

modules/related-posts/jetpack-related-posts.php Outdated Show resolved Hide resolved
@@ -235,7 +258,7 @@ public function get_target_html() {
*
* @returns string
*/
public function get_target_html_unsupported() {
public function get_client_rendered_html_unsupported() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably out of scope of this PR, but is Related Posts supposed to appear in the loop? The doc comment implies not, but I'm seeing them on a test homepage (both on this branch and master).

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 26, 2019
Co-Authored-By: Jefferson Rabb <jefferson.rabb@automattic.com>
@matticbot
Copy link
Contributor

gravityrail, Your synced wpcom patch D30356-code has been updated.

jeffersonrabb
jeffersonrabb previously approved these changes Jul 29, 2019
Copy link
Contributor

@jeffersonrabb jeffersonrabb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

@dereksmart dereksmart removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jul 29, 2019
@dereksmart dereksmart added the [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. label Jul 29, 2019
@dereksmart dereksmart added this to the 7.6 milestone Jul 29, 2019
@dereksmart
Copy link
Member

Added to 7.6 milestone as per request of @gravityrail

@matticbot
Copy link
Contributor

gravityrail, Your synced wpcom patch D30356-code has been updated.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works for me, although the whole section looks pretty bad without any CSS. I don't know if we should ship this change now, without applying basic styles to the related posts.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 29, 2019
@zinigor zinigor merged commit 91c5676 into master Jul 29, 2019
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jul 29, 2019
@zinigor zinigor deleted the try/amp-related-posts branch July 29, 2019 21:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port Related Posts to work with AMP
8 participants