Skip to content

Commit

Permalink
Support AddToAny share (#633)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjoezhang authored Apr 26, 2023
1 parent c8b8456 commit 318adc0
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
9 changes: 6 additions & 3 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,9 +741,12 @@ isso: # <data_isso>
# See: https://theme-next.js.org/docs/third-party-services/post-widgets
# ---------------------------------------------------------------

# AddThis Share. See: https://www.addthis.com
# Go to https://www.addthis.com/dashboard to customize your tools.
add_this_id:
# AddToAny Share. See: https://www.addtoany.com
addtoany:
enable: false
buttons:
- facebook
- twitter


# ---------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions layout/_partials/post/post-share.njk
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,12 @@
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{ theme.add_this_id }}" async="async"></script>
</div>
{%- endif %}

{%- if theme.addtoany.enable %}
<div class="social-like a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
{%- for button in theme.addtoany.buttons %}
<a class="a2a_button_{{ button }}"></a>
{%- endfor %}
</div>
{%- endif %}
3 changes: 3 additions & 0 deletions layout/_third-party/addtoany.njk
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{%- if theme.addtoany.enable %}
{{ next_js('third-party/addtoany.js') }}
{%- endif %}
2 changes: 1 addition & 1 deletion layout/_third-party/index.njk
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@
{%- include 'tags/mermaid.njk' -%}

{%- include 'fancybox.njk' -%}

{%- include 'pace.njk' -%}
{%- include 'addtoany.njk' -%}
6 changes: 5 additions & 1 deletion source/css/_common/components/post/post-widgets.styl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@
font-size: $font-size-small;
margin-top: 1em;
padding-top: 1em;
text-align: center;
flex-wrap();

a {
border-bottom: none;
}
}
8 changes: 8 additions & 0 deletions source/js/third-party/addtoany.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* global NexT */

document.addEventListener('page:loaded', () => {
NexT.utils.getScript('https://static.addtoany.com/menu/page.js', { condition: window.a2a })
.then(() => {
window.a2a.init();
});
});

0 comments on commit 318adc0

Please sign in to comment.