diff --git a/sections/featured-product.liquid b/sections/featured-product.liquid index ef4a357f0f2..c18f1a1be02 100644 --- a/sections/featured-product.liquid +++ b/sections/featured-product.liquid @@ -197,43 +197,12 @@ {%- when 'share' -%} - - - -
- - -
-
+ {% assign share_url = product.selected_variant.url | default: product.url | prepend: request.origin %} + {% render 'share-button-block', + block: block, + share_link: share_url + %} + {%- when 'variant_picker' -%} {%- unless product.has_only_default_variant -%} {%- if block.settings.picker_type == 'button' -%} diff --git a/sections/main-article.liquid b/sections/main-article.liquid index 9081a147392..b89428f6b36 100644 --- a/sections/main-article.liquid +++ b/sections/main-article.liquid @@ -53,42 +53,11 @@ {%- when 'share' -%}
- - -
- - -
-
- + {% assign share_url = request.origin | append: article.url %} + {% render 'share-button-block', + block: block, + share_link: share_url + %}
{%- endcase -%} {%- endfor -%} diff --git a/sections/main-product.liquid b/sections/main-product.liquid index a604992ec74..8e0781de2f0 100644 --- a/sections/main-product.liquid +++ b/sections/main-product.liquid @@ -246,47 +246,12 @@ {{- block.settings.text -}} {%- when 'share' -%} - - -
- - -
-
- + {% assign share_url = product.selected_variant.url | default: product.url | prepend: request.origin %} + {% render 'share-button-block', + block: block, + share_link: share_url + %} + {%- when 'variant_picker' -%} {%- unless product.has_only_default_variant -%} {%- if block.settings.picker_type == 'button' -%} diff --git a/snippets/share-button-block.liquid b/snippets/share-button-block.liquid new file mode 100644 index 00000000000..a7bfd6d82b3 --- /dev/null +++ b/snippets/share-button-block.liquid @@ -0,0 +1,49 @@ +{% comment %} + Renders share button. + Accepts: + - block: {Object} either passing the block/section. + - share_link: {String} url to be added to the input the user will get/copy. + + Usage: + {% render 'share-button-block', + block: block, + share_link: share_url + %} +{% endcomment %} + + + + +
+ + +
+