The associative array returned by _amp_get_amp_js() does not include amp-social-share, which prevents using _amp_add_component_libraries() to include that custom element. Even though the signature states the intent of the latter function being a private implementation, it's quite reasonable to call it directly from a module/theme that is fully tied to amp functionality and prevent duplicating all the code needed to inject the full script tag.

CommentFileSizeAuthor
#2 amp_social_share-2768631-02.patch706 bytesjedihe
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jedihe created an issue. See original summary.

jedihe’s picture

Patch attached.

Also a quick comment: it'd be great if the function itself can be renamed to be public (e.g. amp_add_component_libraries()), since it's quite useful and calling it multiple times won't cause issues like duplication of custom elements.

jedihe’s picture

Status: Active » Needs review
laxman.ghavte’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks good to me.

  • mtift committed f775001 on 7.x-1.x authored by laxman.ghavte
    Issue #2768631 by jedihe, laxman.ghavte: Add amp-social-share to custom...
mtift’s picture

Status: Reviewed & tested by the community » Fixed

Committed and pushed to 7.x-1.x. Thanks guys!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

alexseif’s picture

I applied this patch, but I cannot get the social share to work, it doesn't detect the amp-social-share tag to load the appropriate js, I just added this to a custom field

  <amp-social-share type="email"></amp-social-share>
  <amp-social-share type="facebook"
    data-param-app_id="254325784911610"></amp-social-share>
  <amp-social-share type="gplus"></amp-social-share>
  <amp-social-share type="linkedin"></amp-social-share>
  <amp-social-share type="pinterest"
    data-param-media="https://ampbyexample.com/img/amp.jpg"></amp-social-share>
  <amp-social-share type="tumblr"></amp-social-share>
  <amp-social-share type="twitter"></amp-social-share>
  <amp-social-share type="whatsapp"></amp-social-share>