✨ Finish the post share plugin develop.
This commit is contained in:
commit
f92118257a
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -85,6 +85,8 @@ $post_edit_enable : {{ $P.postEdit.enable }};
|
|||||||
$post_meta_item_text : {{ $P.postMeta.itemText }};
|
$post_meta_item_text : {{ $P.postMeta.itemText }};
|
||||||
$reward_settings_animation : {{ $P.rewardSets.animation }};
|
$reward_settings_animation : {{ $P.rewardSets.animation }};
|
||||||
$post_end_tag_icon : {{ $P.postFooter.tagIcon }};
|
$post_end_tag_icon : {{ $P.postFooter.tagIcon }};
|
||||||
|
$post_share_enable : {{ $P.share.enable }};
|
||||||
|
$post_sharethis_set : {{ isset $P.share "sharethis" }};
|
||||||
|
|
||||||
// TODO find the paramters
|
// TODO find the paramters
|
||||||
$text_align_desktop : {{ $P.textAlign.desktop }};
|
$text_align_desktop : {{ $P.textAlign.desktop }};
|
||||||
|
16
assets/js/third-party/share/addthis.js
vendored
16
assets/js/third-party/share/addthis.js
vendored
@ -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
24
assets/js/third-party/share/addtoany.js
vendored
Normal 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); });
|
||||||
|
});
|
||||||
|
}
|
21
assets/js/third-party/share/sharethis.js
vendored
Normal file
21
assets/js/third-party/share/sharethis.js
vendored
Normal 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);
|
||||||
|
});
|
||||||
|
}
|
@ -90,8 +90,12 @@ analytics:
|
|||||||
|
|
||||||
# 文章分享
|
# 文章分享
|
||||||
# Share
|
# Share
|
||||||
addthis:
|
share:
|
||||||
js: https://s7.addthis.com/js/300/addthis_widget.js
|
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
|
# Comment component
|
||||||
|
@ -935,11 +935,19 @@ params:
|
|||||||
id: # <app_id>
|
id: # <app_id>
|
||||||
color: "#fc6423"
|
color: "#fc6423"
|
||||||
|
|
||||||
# AddThis文章分享功能(服务商已下线,不推荐使用)
|
# 文章分享功能
|
||||||
# 更多信息及配置请参考:https://www.addthis.com
|
share:
|
||||||
# AddThis Share (The service provider has been offline, not recommended for use)
|
enable: true
|
||||||
# See: https://www.addthis.com
|
# 更多信息与配置,请参考:https://sharethis.com
|
||||||
# addThisId: #<Your addthis>
|
# 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
|
||||||
|
|
||||||
|
|
||||||
# ---------------------------------------------------------------
|
# ---------------------------------------------------------------
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
{{ if isset .Site.Params "addthisid" }}
|
|
||||||
<div class="addthis_inline_share_toolbox" style="text-align: center;"></div>
|
|
||||||
{{ end }}
|
|
11
layouts/partials/_thirdparty/share/addtoany.html
vendored
Normal file
11
layouts/partials/_thirdparty/share/addtoany.html
vendored
Normal 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>
|
1
layouts/partials/_thirdparty/share/sharethis.html
vendored
Normal file
1
layouts/partials/_thirdparty/share/sharethis.html
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
<div class="sharethis-inline-share-buttons"></div>
|
@ -139,12 +139,29 @@
|
|||||||
{{ $config = merge $config (dict "utterances" $utterances) }}
|
{{ $config = merge $config (dict "utterances" $utterances) }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with .Site.Params.addThisId }}
|
{{ with .Site.Params.share }}
|
||||||
{{ $addthis := dict
|
|
||||||
"js" $.Site.Data.resources.addthis.js
|
{{ $share := dict "enable" .enable }}
|
||||||
"cfg" (dict "pubid" .)
|
|
||||||
}}
|
{{ if isset . "sharethis" }}
|
||||||
{{ $config = merge $config (dict "addthis" $addthis) }}
|
{{ $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 }}
|
{{ end }}
|
||||||
|
|
||||||
{{ with .Site.Params.siteState.statistic }}
|
{{ with .Site.Params.siteState.statistic }}
|
||||||
|
@ -10,8 +10,21 @@
|
|||||||
<div class="post-eof"></div>
|
<div class="post-eof"></div>
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ partial "post/footer_meta/tags.html" . }}
|
{{ partial "post/footer_meta/tags.html" . }}
|
||||||
{{ if and (not (isset .Params "share")) (not .Params.share) }}
|
{{ $enable := .Params.share | default .Site.Params.share.enable }}
|
||||||
{{ partial "_thirdparty/share/addthis.html" . }}
|
{{ 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 }}
|
{{ end }}
|
||||||
<hr/>
|
<hr/>
|
||||||
{{ partial "post/footer_meta/reward.html" . }}
|
{{ partial "post/footer_meta/reward.html" . }}
|
||||||
|
@ -40,9 +40,22 @@
|
|||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* Share scripts */}}
|
{{/* Share scripts */}}
|
||||||
{{ if isset .Site.Params "addthisid" }}
|
{{/** if and .Site.Params.share.enable (isset .Site.Params "sharethisid") }}
|
||||||
{{ $addthisjs := resources.Get "js/third-party/share/addthis.js" }}
|
{{ $sharethisjs := resources.Get "js/third-party/share/sharethis.js" }}
|
||||||
{{ $nextjs = $nextjs | append $addthisjs }}
|
{{ $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 }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* Comments scripts */}}
|
{{/* Comments scripts */}}
|
||||||
|
Loading…
Reference in New Issue
Block a user