Support AddToAny share (#633)

This commit is contained in:
Mimi 2023-04-27 00:49:17 +08:00 committed by GitHub
parent c8b84567cc
commit 318adc0227
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 5 deletions

View File

@ -741,9 +741,12 @@ isso: # <data_isso>
# See: https://theme-next.js.org/docs/third-party-services/post-widgets # See: https://theme-next.js.org/docs/third-party-services/post-widgets
# --------------------------------------------------------------- # ---------------------------------------------------------------
# AddThis Share. See: https://www.addthis.com # AddToAny Share. See: https://www.addtoany.com
# Go to https://www.addthis.com/dashboard to customize your tools. addtoany:
add_this_id: enable: false
buttons:
- facebook
- twitter
# --------------------------------------------------------------- # ---------------------------------------------------------------

View File

@ -3,3 +3,12 @@
<script src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{ theme.add_this_id }}" async="async"></script> <script src="//s7.addthis.com/js/300/addthis_widget.js#pubid={{ theme.add_this_id }}" async="async"></script>
</div> </div>
{%- endif %} {%- 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
layout/_third-party/addtoany.njk vendored Normal file
View File

@ -0,0 +1,3 @@
{%- if theme.addtoany.enable %}
{{ next_js('third-party/addtoany.js') }}
{%- endif %}

View File

@ -16,5 +16,5 @@
{%- include 'tags/mermaid.njk' -%} {%- include 'tags/mermaid.njk' -%}
{%- include 'fancybox.njk' -%} {%- include 'fancybox.njk' -%}
{%- include 'pace.njk' -%} {%- include 'pace.njk' -%}
{%- include 'addtoany.njk' -%}

View File

@ -3,5 +3,9 @@
font-size: $font-size-small; font-size: $font-size-small;
margin-top: 1em; margin-top: 1em;
padding-top: 1em; padding-top: 1em;
text-align: center; flex-wrap();
a {
border-bottom: none;
}
} }

8
source/js/third-party/addtoany.js vendored Normal file
View File

@ -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();
});
});