🎨 🐛 Rename file & path & remove unused file.

This commit is contained in:
elkan1788
2025-01-05 16:40:58 +08:00
parent 27d3a33222
commit 351d6728d0
48 changed files with 27 additions and 482 deletions

View File

@@ -0,0 +1,33 @@
/* Artalk comment plugin */
NexT.plugins.comments.artalk = function() {
const element = '.artalk-container';
if (!NexT.CONFIG.artalk
|| !NexT.utils.checkDOMExist(element)) return;
const artalk_js = NexT.utils.getCDNResource(NexT.CONFIG.artalk.js);
const {
site,
placeholder,
server,
} = NexT.CONFIG.artalk.cfg;
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(artalk_js, function(){
const artalk_css = NexT.utils.getCDNResource(NexT.CONFIG.artalk.css);
NexT.utils.getStyle(artalk_css);
new Artalk({
el : element,
pageKey : NexT.CONFIG.permalink,
pageTitle : NexT.CONFIG.title,
server : server,
site : site,
locale : NexT.CONFIG.lang,
placeholder : placeholder,
darkMode : 'auto'
});
});
NexT.utils.hiddeLodingCmp(element);
});
}

View File

@@ -0,0 +1,42 @@
/* Giscus comment plugin */
NexT.plugins.comments.giscus = function() {
const element = '.giscus-container';
if (!NexT.CONFIG.page.comments
|| !NexT.CONFIG.giscus
|| !NexT.utils.checkDOMExist(element)) return;
const {
category,
categoryid,
emit,
inputposition,
mapping,
reactions,
repo,
repoid,
theme } = NexT.CONFIG.giscus.cfg;
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(NexT.CONFIG.giscus.js, {
attributes: {
'async' : true,
'crossorigin' : 'anonymous',
'data-repo' : repo,
'data-repo-id' : repoid,
'data-category' : category,
'data-category-id' : categoryid,
'data-mapping' : mapping,
'data-reactions-enabled' : reactions ? 1:0,
'data-emit-metadata' : emit ? 1:0,
'data-input-position' : inputposition,
'data-theme' : theme,
'data-lang' : NexT.CONFIG.lang,
'data-loading' : 'lazy'
},
parentNode: document.querySelector(element)
});
NexT.utils.hiddeLodingCmp(element);
});
}

View File

@@ -0,0 +1,17 @@
/* LiveRe comment plugin */
NexT.plugins.comments.livere = function() {
const element = '#lv-container';
if (!NexT.CONFIG.livere
|| !NexT.utils.checkDOMExist(element)) return;
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(NexT.CONFIG.livere.js, {
attributes: {
async: true
},
parentNode: document.querySelector(element)
});
NexT.utils.hiddeLodingCmp(element);
});
}

View File

@@ -0,0 +1,28 @@
/* Utterances comment plugin */
NexT.plugins.comments.utterances = function() {
const element = '.utterances-container';
if (!NexT.CONFIG.utterances
|| !NexT.utils.checkDOMExist(element)) return;
const {
repo,
issueterm,
label,
theme } = NexT.CONFIG.utterances.cfg;
NexT.utils.lazyLoadComponent(element, function() {
NexT.utils.getScript(NexT.CONFIG.utterances.js, {
attributes: {
'async' : true,
'crossorigin' : 'anonymous',
'repo' : repo,
'issue-term' : issueterm,
'label' : label,
'theme' : theme
},
parentNode: document.querySelector(element)
});
NexT.utils.hiddeLodingCmp(element);
});
}

View File

@@ -0,0 +1,53 @@
/* Waline comment plugin */
NexT.plugins.comments.waline = function() {
const element = '.waline-container';
if (!NexT.CONFIG.waline
|| !NexT.utils.checkDOMExist(element)) return;
const {
emoji,
imguploader,
placeholder,
sofa,
requiredmeta,
serverurl,
wordlimit,
reaction,
reactiontext,
reactiontitle
} = NexT.CONFIG.waline.cfg;
const waline_js = NexT.utils.getCDNResource(NexT.CONFIG.waline.js);
let locale = {
placeholder : placeholder,
sofa : sofa,
reactionTitle : reactiontitle
};
reactiontext.forEach(function(value, index){
locale['reaction'+index] = value;
});
NexT.utils.lazyLoadComponent(element, function () {
NexT.utils.getScript(waline_js, function(){
const waline_css = NexT.utils.getCDNResource(NexT.CONFIG.waline.css);
NexT.utils.getStyle(waline_css, 'before');
Waline.init({
locale,
el : element,
emoji : emoji,
imageUploader : imguploader,
wordLimit : wordlimit,
requiredMeta : requiredmeta,
reaction : reaction,
serverURL : serverurl,
lang : NexT.CONFIG.lang,
dark : 'html[data-theme="dark"]'
});
NexT.utils.hiddeLodingCmp(element);
})
});
}

View File

@@ -0,0 +1,60 @@
/* Waline3 comment plugin */
NexT.plugins.comments.waline3 = function () {
const element = '.waline3-container';
if (!NexT.CONFIG.waline3
|| !NexT.utils.checkDOMExist(element)) return;
const {
emoji,
search,
imguploader,
placeholder,
sofa,
requiredmeta,
serverurl,
wordlimit,
reaction,
reactiontext,
reactiontitle
} = NexT.CONFIG.waline3.cfg;
const waline_js = NexT.utils.getCDNResource(NexT.CONFIG.waline3.js);
NexT.utils.lazyLoadComponent(element, () => {
const waline_css = NexT.utils.getCDNResource(NexT.CONFIG.waline3.css);
NexT.utils.getStyle(waline_css, 'before');
let waline_script = `
let locale = {
placeholder : '${placeholder}',
sofa : '${sofa}',
reactionTitle : '${reactiontitle}'
};
let recatt = ${JSON.stringify(reactiontext)}
recatt.forEach(function(value, index){
locale['reaction'+index] = value;
});
import('${waline_js}').then((Waline) => {
Waline.init({
locale,
el : '${element}',
emoji : ${emoji},
search : ${search},
imageUploader : ${imguploader},
wordLimit : ${wordlimit},
requiredMeta : ${JSON.stringify(requiredmeta)},
reaction : ${reaction},
serverURL : '${serverurl}',
dark : 'html[data-theme="dark"]'
});
NexT.utils.hiddeLodingCmp('${element}');
});
`;
NexT.utils.getScript(null, { module: true, textContent: waline_script });
});
}

View File

@@ -0,0 +1,66 @@
/* Page's view & comment counter plugin */
NexT.plugins.others.counter = function () {
let pageview_js = undefined;
let comment_js = undefined;
const post_meta = NexT.CONFIG.postmeta;
const views = post_meta.views;
if (views != undefined && views.enable) {
let pageview_el = '#pageview-count';
switch (views.plugin) {
case 'waline':
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.pagecnt);
NexT.utils.getScript(pageview_js, function () {
Waline.pageviewCount({
selector : pageview_el,
serverURL: NexT.CONFIG.waline.cfg.serverurl
});
});
break;
case 'waline3':
pageview_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline3.pagecnt);
let pageview_script = `
import('${pageview_js}').then((Waline) => {
Waline.pageviewCount({
selector : '${pageview_el}',
serverURL: '${NexT.CONFIG.waline3.cfg.serverurl}'
})
});
`;
NexT.utils.getScript(null, { module: true, textContent: pageview_script });
break;
}
}
const comments = post_meta.comments;
if (comments != undefined && comments.enable) {
let comments_el = '#comments-count';
switch (comments.plugin) {
case 'waline':
comment_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline.commentcnt);
NexT.utils.getScript(comment_js, function () {
Waline.commentCount({
selector : comments_el,
serverURL: NexT.CONFIG.waline.cfg.serverurl
});
});
break;
case 'waline3':
comment_js = NexT.utils.getCDNResource(NexT.CONFIG.page.waline3.commentcnt);
let comment_script = `
import('${comment_js}').then((Waline) => {
Waline.commentCount({
selector : '${comments_el}',
serverURL: '${NexT.CONFIG.waline3.cfg.serverurl}'
})
});
`;
NexT.utils.getScript(null, { module: true, textContent: comment_script });
break;
}
}
}

View File

@@ -0,0 +1,17 @@
/* 51La sidebar data widget */
NexT.plugins.others.lawidget = function() {
const element = '#siteinfo-card-widget';
const lawt_js = NexT.CONFIG.lawidget.js.replace('laId', NexT.CONFIG.lawidget.id);
NexT.utils.lazyLoadComponent(element, function () {
NexT.utils.getScript(lawt_js,{
attributes: {
id: 'LA-DATA-WIDGET',
crossorigin: 'anonymous',
charset: 'UTF-8',
defer: true
},
parentNode: document.getElementById('la-siteinfo-widget')
}, NexT.utils.fmtLaWidget());
});
}

View File

@@ -0,0 +1,49 @@
/* Math render plugin */
NexT.plugins.others.math = function() {
const render = NexT.CONFIG.page.math.render;
if (render === 'mathjax') {
const render_js = NexT.utils.getCDNResource(NexT.CONFIG.page.math.js);
const mathjaxCfg = `
window.MathJax = {
// 自定义内联数学公式的分隔符号
tex: {
inlineMath: [['$', '$'], ['\\(', '\\)']]
},
// SVG 渲染配置为全局共享字体缓存
svg: {
fontCache: 'global'
},
// 排除特定的HTML标签避免过度渲染
options: {
skipHtmlTags: ["script", "noscript", "style", "textarea", "pre", "footer"],
}
};
`;
NexT.utils.getScript(null, { textContent: mathjaxCfg });
NexT.utils.getScript(render_js, { attributes: { id: "MathJax-script", "async": true }});
}
if (render === 'katex') {
const render_css = NexT.utils.getCDNResource(NexT.CONFIG.page.math.css);
NexT.utils.getStyle(render_css);
const render_js_list = NexT.CONFIG.page.math.js;
render_js_list.forEach(js => {
const js_loader = NexT.utils.getScript(NexT.utils.getCDNResource(js));
if(js.name === 'auto-render') {
js_loader.then(function(){
renderMathInElement(document.body, {
delimiters: [
{left: '$$', right: '$$', display: true},
{left: '$', right: '$', display: false},
{left: '\\(', right: '\\)', display: false},
{left: '\\[', right: '\\]', display: true}
],
throwOnError : false
})
});
}
});
}
}

View File

@@ -0,0 +1,15 @@
/* Mermaid plugin */
NexT.plugins.others.mermaid = function() {
const mermaid_js = NexT.utils.getCDNResource(NexT.CONFIG.page.mermaid.js);
NexT.utils.getScript(mermaid_js, function(){
mermaid.initialize({
sequence: {
showSequenceNumbers: true,
actorMargin: 50,
diagramMarginX:10,
diagramMarginY:10
}
});
});
}

View File

@@ -0,0 +1,9 @@
/* Google translate plugin */
NexT.plugins.others.translate = function() {
const element = '#gtranslate';
if (!NexT.utils.checkDOMExist(element)) return;
NexT.utils.lazyLoadComponent(element, function() {
window.translateelement_styles='/css/google-translate.min.css';
NexT.utils.getScript('/js/3rd/google-translate.min.js');
});
}

View File

@@ -0,0 +1,142 @@
/* Algolia search engine */
NexT.plugins.search.algolia = function() {
const algoliajs = NexT.utils.getCDNResource(NexT.CONFIG.algolia.js);
const instantschjs = NexT.utils.getCDNResource(NexT.CONFIG.algolia.instantjs);
NexT.utils.getScript(algoliajs);
NexT.utils.getScript(instantschjs, function() {
const { indexname, appid, apikey, hits } = NexT.CONFIG.algolia.cfg;
const indexName = indexname;
const search = instantsearch({
indexName,
searchClient: algoliasearch(appid, apikey),
searchFunction: helper => {
if (document.querySelector('.search-input').value) {
helper.search();
}
}
});
const markKeyWords = function(content) {
return content.replaceAll("<mark>", '<mark class="search-keyword">');
};
if (typeof pjax === 'object') {
search.on('render', () => {
pjax.refresh(document.querySelector('.algolia-hits'));
});
}
// Registering Widgets
search.addWidgets([
instantsearch.widgets.configure({
hitsPerPage: hits.perpage || 10
}),
instantsearch.widgets.searchBox({
container: '.search-input-container',
placeholder: NexT.CONFIG.i18n.placeholder,
// Hide default icons of algolia search
showReset: false,
showSubmit: false,
showLoadingIndicator: true,
cssClasses: {
input: 'search-input'
}
}),
instantsearch.widgets.stats({
container: '.algolia-stats',
templates: {
text: data => {
const stats = NexT.CONFIG.i18n.hits_time
.replace('${hits}', data.nbHits)
.replace('${time}', data.processingTimeMS);
return `${stats}`;
}
},
cssClasses: {
text: 'search-stats'
}
}),
instantsearch.widgets.hits({
container: '.algolia-hits',
escapeHTML: true,
templates: {
item: data => {
const { title, content } = data._highlightResult;
let result = `<a href="${data.permalink}" class="search-result-title">${markKeyWords(title.value)}</a>`;
//const content = excerpt || excerptStrip || content;
if (content && content.value) {
const div = document.createElement('div');
div.innerHTML = markKeyWords(content.value);
result += `<a href="${data.permalink}"><p class="search-result">${div.innerHTML.substring(0, 200)}...</p></a>`;
}
return result;
},
empty: data => {
return `<div class="algolia-hits-empty">
${NexT.CONFIG.i18n.empty.replace('${query}', data.query)}
</div>`;
}
},
cssClasses: {
list: 'search-result-list'
}
}),
instantsearch.widgets.pagination({
container: '.algolia-pagination',
scrollTo: false,
showFirst: true,
showLast: true,
templates: {
first: '<i class="fa fa-angle-double-left"></i>',
last: '<i class="fa fa-angle-double-right"></i>',
previous: '<i class="fa fa-angle-left"></i>',
next: '<i class="fa fa-angle-right"></i>'
},
cssClasses: {
list: ['pagination', 'algolia-pagination'],
item: 'pagination-item',
link: 'page-number',
selectedItem: 'current',
disabledItem: 'disabled-item'
}
})
]);
search.start();
// Handle and trigger popup window
document.querySelectorAll('.popup-trigger').forEach(element => {
element.addEventListener('click', () => {
document.body.classList.add('search-active');
setTimeout(() => document.querySelector('.search-input').focus(), 500);
});
});
// Monitor main search box
const onPopupClose = () => {
document.body.classList.remove('search-active');
};
document.querySelector('.search-pop-overlay').addEventListener('click', event => {
if (event.target === document.querySelector('.search-pop-overlay')) {
onPopupClose();
}
});
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
document.addEventListener('pjax:success', onPopupClose);
window.addEventListener('keyup', event => {
if (event.key === 'Escape') {
onPopupClose();
}
});
});
}

View File

@@ -0,0 +1,326 @@
/* LocalSearch engine */
class LocalSearch {
constructor({
path = '',
unescape = false,
top_n_per_article = 1
}) {
this.path = path;
this.unescape = unescape;
this.top_n_per_article = top_n_per_article;
this.isfetched = false;
this.datas = null;
}
getIndexByWord(words, text, caseSensitive = false) {
const index = [];
const included = new Set();
if (!caseSensitive) {
text = text.toLowerCase();
}
words.forEach(word => {
if (this.unescape) {
const div = document.createElement('div');
div.innerText = word;
word = div.innerHTML;
}
const wordLen = word.length;
if (wordLen === 0) return;
let startPosition = 0;
let position = -1;
if (!caseSensitive) {
word = word.toLowerCase();
}
while ((position = text.indexOf(word, startPosition)) > -1) {
index.push({ position, word });
included.add(word);
startPosition = position + wordLen;
}
});
// Sort index by position of keyword
index.sort((left, right) => {
if (left.position !== right.position) {
return left.position - right.position;
}
return right.word.length - left.word.length;
});
return [index, included];
}
// Merge hits into slices
mergeIntoSlice(start, end, index) {
let item = index[0];
let { position, word } = item;
const hits = [];
const count = new Set();
while (position + word.length <= end && index.length !== 0) {
count.add(word);
hits.push({
position,
length: word.length
});
const wordEnd = position + word.length;
// Move to next position of hit
index.shift();
while (index.length !== 0) {
item = index[0];
position = item.position;
word = item.word;
if (wordEnd > position) {
index.shift();
} else {
break;
}
}
}
return {
hits,
start,
end,
count: count.size
};
}
// Highlight title and content
highlightKeyword(val, slice) {
let result = '';
let index = slice.start;
for (const { position, length } of slice.hits) {
result += val.substring(index, position);
index = position + length;
result += `<mark class="search-keyword">${val.substr(position, length)}</mark>`;
}
result += val.substring(index, slice.end);
return result;
}
getResultItems(keywords) {
const resultItems = [];
this.datas.forEach(({ title, content, url }) => {
// The number of different keywords included in the article.
const [indexOfTitle, keysOfTitle] = this.getIndexByWord(keywords, title);
const [indexOfContent, keysOfContent] = this.getIndexByWord(keywords, content);
const includedCount = new Set([...keysOfTitle, ...keysOfContent]).size;
// Show search results
const hitCount = indexOfTitle.length + indexOfContent.length;
if (hitCount === 0) return;
const slicesOfTitle = [];
if (indexOfTitle.length !== 0) {
slicesOfTitle.push(this.mergeIntoSlice(0, title.length, indexOfTitle));
}
let slicesOfContent = [];
while (indexOfContent.length !== 0) {
const item = indexOfContent[0];
const { position } = item;
// Cut out 100 characters. The maxlength of .search-input is 80.
const start = Math.max(0, position - 20);
const end = Math.min(content.length, position + 80);
slicesOfContent.push(this.mergeIntoSlice(start, end, indexOfContent));
}
// Sort slices in content by included keywords' count and hits' count
slicesOfContent.sort((left, right) => {
if (left.count !== right.count) {
return right.count - left.count;
} else if (left.hits.length !== right.hits.length) {
return right.hits.length - left.hits.length;
}
return left.start - right.start;
});
// Select top N slices in content
const upperBound = parseInt(this.top_n_per_article, 10);
if (upperBound >= 0) {
slicesOfContent = slicesOfContent.slice(0, upperBound);
}
let resultItem = '';
url = new URL(url, location.origin);
url.searchParams.append('highlight', keywords.join(' '));
if (slicesOfTitle.length !== 0) {
resultItem += `<li><a href="${url.href}" class="search-result-title">${this.highlightKeyword(title, slicesOfTitle[0])}</a>`;
} else {
resultItem += `<li><a href="${url.href}" class="search-result-title">${title}</a>`;
}
slicesOfContent.forEach(slice => {
resultItem += `<a href="${url.href}"><p class="search-result">${this.highlightKeyword(content, slice)}...</p></a>`;
});
resultItem += '</li>';
resultItems.push({
item: resultItem,
id : resultItems.length,
hitCount,
includedCount
});
});
return resultItems;
}
fetchData() {
const isXml = !this.path.endsWith('json');
fetch(this.path)
.then(response => response.text())
.then(res => {
// Get the contents from search data
this.isfetched = true;
this.datas = isXml ? [...new DOMParser().parseFromString(res, 'text/xml').querySelectorAll('entry')].map(element => ({
title : element.querySelector('title').textContent,
content: element.querySelector('content').textContent,
url : element.querySelector('url').textContent
})) : JSON.parse(res);
// Only match articles with non-empty titles
this.datas = this.datas.filter(data => data.title).map(data => {
data.title = data.title.trim();
data.content = data.content ? data.content.trim().replace(/<[^>]+>/g, '') : '';
data.url = decodeURIComponent(data.url).replace(/\/{2,}/g, '/');
return data;
});
// Remove loading animation
window.dispatchEvent(new Event('search:loaded'));
});
}
// Highlight by wrapping node in mark elements with the given class name
highlightText(node, slice, className) {
const val = node.nodeValue;
let index = slice.start;
const children = [];
for (const { position, length } of slice.hits) {
const text = document.createTextNode(val.substring(index, position));
index = position + length;
const mark = document.createElement('mark');
mark.className = className;
mark.appendChild(document.createTextNode(val.substr(position, length)));
children.push(text, mark);
}
node.nodeValue = val.substring(index, slice.end);
children.forEach(element => {
node.parentNode.insertBefore(element, node);
});
}
// Highlight the search words provided in the url in the text
highlightSearchWords(body) {
const params = new URL(location.href).searchParams.get('highlight');
const keywords = params ? params.split(' ') : [];
if (!keywords.length || !body) return;
const walk = document.createTreeWalker(body, NodeFilter.SHOW_TEXT, null);
const allNodes = [];
while (walk.nextNode()) {
if (!walk.currentNode.parentNode.matches('button, select, textarea')) allNodes.push(walk.currentNode);
}
allNodes.forEach(node => {
const [indexOfNode] = this.getIndexByWord(keywords, node.nodeValue);
if (!indexOfNode.length) return;
const slice = this.mergeIntoSlice(0, node.nodeValue.length, indexOfNode);
this.highlightText(node, slice, 'search-keyword');
});
}
}
NexT.plugins.search.localsearch = function() {
if (! NexT.CONFIG.localSearch.path) {
// Search DB path
console.warn('`search indexes file` is not configurate!');
return;
}
const localSearch = new LocalSearch({
path : NexT.CONFIG.localSearch.path,
top_n_per_article: NexT.CONFIG.localSearch.topnperarticle,
unescape : NexT.CONFIG.localSearch.unescape
});
const input = document.querySelector('.search-input');
const inputEventFunction = () => {
if (!localSearch.isfetched) return;
const searchText = input.value.trim().toLowerCase();
const keywords = searchText.split(/[-\s]+/);
const container = document.querySelector('.search-result-container');
let resultItems = [];
if (searchText.length > 0) {
// Perform local searching
resultItems = localSearch.getResultItems(keywords);
}
if (keywords.length === 1 && keywords[0] === '') {
container.classList.add('no-result');
container.innerHTML = '<div class="search-result-icon"><i class="fa fa-search fa-5x"></i></div>';
} else if (resultItems.length === 0) {
container.classList.add('no-result');
container.innerHTML = '<div class="search-result-icon"><i class="far fa-frown fa-5x"></i></div>';
} else {
resultItems.sort((left, right) => {
if (left.includedCount !== right.includedCount) {
return right.includedCount - left.includedCount;
} else if (left.hitCount !== right.hitCount) {
return right.hitCount - left.hitCount;
}
return right.id - left.id;
});
const stats = NexT.CONFIG.i18n.hits.replace('${hits}', resultItems.length);
container.classList.remove('no-result');
container.innerHTML = `<div class="search-stats">${stats}</div>
<hr>
<ul class="search-result-list">${resultItems.map(result => result.item).join('')}</ul>`;
if (typeof pjax === 'object') pjax.refresh(container);
}
};
localSearch.highlightSearchWords(document.querySelector('.post-body'));
if (NexT.CONFIG.localSearch.preload) {
localSearch.fetchData();
}
if (NexT.CONFIG.localSearch.trigger === 'auto') {
input.addEventListener('input', inputEventFunction);
} else {
document.querySelector('.search-icon').addEventListener('click', inputEventFunction);
input.addEventListener('keypress', event => {
if (event.key === 'Enter') {
inputEventFunction();
}
});
}
window.addEventListener('search:loaded', inputEventFunction);
// Handle and trigger popup window
document.querySelectorAll('.popup-trigger').forEach(element => {
element.addEventListener('click', () => {
document.body.classList.add('search-active');
// Wait for search-popup animation to complete
setTimeout(() => input.focus(), 500);
if (!localSearch.isfetched) localSearch.fetchData();
});
});
// Monitor main search box
const onPopupClose = () => {
document.body.classList.remove('search-active');
};
document.querySelector('.search-pop-overlay').addEventListener('click', event => {
if (event.target === document.querySelector('.search-pop-overlay')) {
onPopupClose();
}
});
document.querySelector('.popup-btn-close').addEventListener('click', onPopupClose);
document.addEventListener('pjax:success', () => {
localSearch.highlightSearchWords(document.querySelector('.post-body'));
onPopupClose();
});
window.addEventListener('keyup', event => {
if (event.key === 'Escape') {
onPopupClose();
}
});
}

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