🔥💄 Remove sharethis & add others.

This commit is contained in:
elkan1788 2024-08-05 20:38:20 +08:00
parent 85c3eb9d3b
commit e6ee562996
13 changed files with 150 additions and 37 deletions

View File

@ -91,3 +91,21 @@
}
}
}
@if $post_share_enable {
.post-share-tools {
display: flex;
justify-content: center;
a {
border: 0px;
}
}
@if $post_sharethis_set {
.st-cmp-settings {
display: none;
}
}
}

View File

@ -85,6 +85,8 @@ $post_edit_enable : {{ $P.postEdit.enable }};
$post_meta_item_text : {{ $P.postMeta.itemText }};
$reward_settings_animation : {{ $P.rewardSets.animation }};
$post_end_tag_icon : {{ $P.postFooter.tagIcon }};
$post_share_enable : {{ $P.share.enable }};
$post_sharethis_set : {{ isset $P.share "sharethis" }};
// TODO find the paramters
$text_align_desktop : {{ $P.textAlign.desktop }};

View File

@ -1,16 +0,0 @@
/* AddThis share plugin */
NexT.plugins.share.addthis = function() {
const element = '.addthis_inline_share_toolbox';
if (!NexT.CONFIG.addthis || !NexT.utils.checkDOMExist(element)) return;
const addthis_js = NexT.CONFIG.addthis.js + '?pubid=' + NexT.CONFIG.addthis.cfg.pubid;
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(addthis_js, {
attributes: {
async: false
},
parentNode: document.querySelector(element)
});
});
}

24
assets/js/third-party/share/addtoany.js vendored Normal file
View File

@ -0,0 +1,24 @@
/* Addtoany share plugin */
NexT.plugins.share.addtoany = function() {
const element = '.a2a_kit';
if (!NexT.CONFIG.share.enable || !NexT.utils.checkDOMExist(element)) return;
const addtoany = NexT.CONFIG.share.addtoany;
if (!addtoany) return;
NexT.utils.lazyLoadComponent(element, function() {
let addtoany_cfg = `
var a2a_config = a2a_config || {};
a2a_config.onclick = 1;
a2a_config.locale = "${addtoany.locale}";
a2a_config.num_services = ${addtoany.num};
`;
NexT.utils.getScript(null, {
textContent: addtoany_cfg
});
NexT.utils.getScript(addtoany.js, () => { NexT.utils.hiddeLodingCmp(element); });
});
}

View File

@ -0,0 +1,21 @@
/* Sharethis share plugin */
NexT.plugins.share.sharethis = function() {
const element = '.sharethis-inline-share-buttons';
if (!NexT.CONFIG.share.enable || !NexT.utils.checkDOMExist(element)) return;
const sharethis = NexT.CONFIG.share.sharethis;
if (!sharethis) return;
const sharethis_js = sharethis.js.replace(/id/, sharethis.id);
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(sharethis_js, {
attributes: {
async: 'async'
}
});
NexT.utils.hiddeLodingCmp(element);
});
}

View File

@ -90,8 +90,12 @@ analytics:
# 文章分享
# Share
addthis:
js: https://s7.addthis.com/js/300/addthis_widget.js
share:
sharethis:
js: https://platform-api.sharethis.com/js/sharethis.js#property=id&product=inline-share-buttons&source=platform
addtoany:
js: https://static.addtoany.com/menu/page.js
# 评论组件
# Comment component

View File

@ -935,11 +935,19 @@ params:
id: # <app_id>
color: "#fc6423"
# AddThis文章分享功能服务商已下线不推荐使用
# 更多信息及配置请参考https://www.addthis.com
# AddThis Share (The service provider has been offline, not recommended for use)
# See: https://www.addthis.com
# addThisId: #<Your addthis>
# 文章分享功能
share:
enable: true
# 更多信息与配置请参考https://sharethis.com
# For more information and configuration, please refer to:https://sharethis.com
# sharethis:
# id: #<sharethis_id>
# 简单的在线分享没有统计数据功能更多信息可参考https://www.addtoany.com/
# Simple online sharing without statistical data function.
# For more information, please refer to: https://www.addtoany.com/
addtoany:
locale: zh-CN
num_services: 8
# ---------------------------------------------------------------

View File

@ -1,3 +0,0 @@
{{ if isset .Site.Params "addthisid" }}
<div class="addthis_inline_share_toolbox" style="text-align: center;"></div>
{{ end }}

View File

@ -0,0 +1,11 @@
<div class="a2a_kit a2a_kit_size_32 a2a_default_style">
<a class="a2a_dd" href="https://www.addtoany.com/share"></a>
<a class="a2a_button_wechat"></a>
<a class="a2a_button_qzone"></a>
<a class="a2a_button_sina_weibo"></a>
<a class="a2a_button_douban"></a>
<a class="a2a_button_facebook"></a>
<a class="a2a_button_x"></a>
<a class="a2a_button_email"></a>
<a class="a2a_button_printfriendly"></a>
</div>

View File

@ -0,0 +1 @@
<div class="sharethis-inline-share-buttons"></div>

View File

@ -139,12 +139,29 @@
{{ $config = merge $config (dict "utterances" $utterances) }}
{{ end }}
{{ with .Site.Params.addThisId }}
{{ $addthis := dict
"js" $.Site.Data.resources.addthis.js
"cfg" (dict "pubid" .)
}}
{{ $config = merge $config (dict "addthis" $addthis) }}
{{ with .Site.Params.share }}
{{ $share := dict "enable" .enable }}
{{ if isset . "sharethis" }}
{{ $sharethis := dict
"js" $.Site.Data.resources.share.sharethis.js
"id" .sharethis.id
}}
{{ $share = merge $share (dict "sharethis" $sharethis) }}
{{ end }}
{{ if isset . "addtoany" }}
{{ $addtoany := dict
"js" $.Site.Data.resources.share.addtoany.js
"locale" .addtoany.locale
"num" .addtoany.num_services
}}
{{ $share = merge $share (dict "addtoany" $addtoany) }}
{{ end }}
{{ $config = merge $config (dict "share" $share) }}
{{ end }}
{{ with .Site.Params.siteState.statistic }}

View File

@ -10,8 +10,21 @@
<div class="post-eof"></div>
{{ else }}
{{ partial "post/footer_meta/tags.html" . }}
{{ if and (not (isset .Params "share")) (not .Params.share) }}
{{ partial "_thirdparty/share/addthis.html" . }}
{{ $enable := .Params.share | default .Site.Params.share.enable }}
{{ with .Site.Params.share }}
{{ if $enable }}
<div class="post-share-tools">
<div class="post-share-loading">
<i class="fa-solid fa-ellipsis fa-spin"></i>
</div>
{{ if isset . "sharethis" }}
{{ partial "_thirdparty/share/sharethis.html" }}
{{ end }}
{{ if isset . "addtoany" }}
{{ partial "_thirdparty/share/addtoany.html" }}
{{ end }}
</div>
{{ end }}
{{ end }}
<hr/>
{{ partial "post/footer_meta/reward.html" . }}

View File

@ -40,9 +40,22 @@
{{ end }}
{{/* Share scripts */}}
{{ if isset .Site.Params "addthisid" }}
{{ $addthisjs := resources.Get "js/third-party/share/addthis.js" }}
{{ $nextjs = $nextjs | append $addthisjs }}
{{/** if and .Site.Params.share.enable (isset .Site.Params "sharethisid") }}
{{ $sharethisjs := resources.Get "js/third-party/share/sharethis.js" }}
{{ $nextjs = $nextjs | append $sharethisjs }}
{{ end **/}}
{{ with .Site.Params.share }}
{{ if or .enable .Params.share }}
{{ if isset . "sharethis" }}
{{ $sharethisjs := resources.Get "js/third-party/share/sharethis.js" }}
{{ $nextjs = $nextjs | append $sharethisjs }}
{{ end }}
{{ if isset . "addtoany" }}
{{ $addtoanyjs := resources.Get "js/third-party/share/addtoany.js" }}
{{ $nextjs = $nextjs | append $addtoanyjs }}
{{ end }}
{{ end }}
{{ end }}
{{/* Comments scripts */}}