[feat] share & license in wiki
This commit is contained in:
parent
ca53ce0b58
commit
d2773b127e
|
@ -2,63 +2,82 @@
|
||||||
function layoutDiv() {
|
function layoutDiv() {
|
||||||
var el = '';
|
var el = '';
|
||||||
var item = [];
|
var item = [];
|
||||||
if (page.references && page.references.length > 0) {
|
if (page.references?.length > 0) {
|
||||||
item.push('references');
|
item.push('references');
|
||||||
}
|
}
|
||||||
if (page.layout !== 'wiki') {
|
if (theme.article.license?.length > 0) {
|
||||||
if (theme.article.license && theme.article.license.length > 0) {
|
item.push('license');
|
||||||
item.push('license');
|
}
|
||||||
}
|
if (theme.article.share?.length > 0) {
|
||||||
if (theme.article.share && theme.article.share.length > 0) {
|
item.push('share');
|
||||||
item.push('share');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (item.length === 0) {
|
if (item.length === 0) {
|
||||||
return el;
|
return el;
|
||||||
}
|
}
|
||||||
el += '<div class="article-footer reveal fs14">';
|
el += '<div class="article-footer reveal fs14">';
|
||||||
if (page.references && page.references.length > 0) {
|
if (page.references?.length > 0) {
|
||||||
el += '<section id="references">';
|
function refList() {
|
||||||
el += '<div class="header">';
|
var el = '';
|
||||||
el += '<span>' + __('meta.references') + '</span>';
|
page.references.forEach((item, i) => {
|
||||||
el += '</div>';
|
el += '<li class="post-title">';
|
||||||
el += '<div class="body"><ul>';
|
el += '<a href="' + item.url + '"';
|
||||||
page.references.forEach((item, i) => {
|
if (item.url.includes('://')) {
|
||||||
el += '<li class="post-title">';
|
el += ' target="_blank" rel="external nofollow noopener noreferrer">';
|
||||||
el += '<a href="' + item.url + '"';
|
} else {
|
||||||
if (item.url.includes('://')) {
|
el += ' rel="noopener noreferrer">';
|
||||||
el += ' target="_blank" rel="external nofollow noopener noreferrer">';
|
}
|
||||||
} else {
|
el += item.title || item.url;
|
||||||
el += ' rel="noopener noreferrer">';
|
el += '</a>';
|
||||||
}
|
el += '</li>';
|
||||||
el += item.title || item.url;
|
});
|
||||||
el += '</a>';
|
return el;
|
||||||
el += '</li>';
|
}
|
||||||
});
|
el += `
|
||||||
el += '</ul></div>';
|
<section id="references">
|
||||||
el += '</section>';
|
<div class="header"><span>${__('meta.references')}</span></div>
|
||||||
|
<div class="body">
|
||||||
|
<ul>${refList()}</ul>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var license = ''
|
||||||
if (page.layout == 'post') {
|
if (page.layout == 'post') {
|
||||||
if (theme.article.license && page.license != false) {
|
if (theme.article.license && (page.license != false)) {
|
||||||
el += '<section id="license">';
|
license = markdown(page.license || theme.article.license)
|
||||||
el += '<div class="header">';
|
|
||||||
el += '<span>' + __('meta.license') + '</span>';
|
|
||||||
el += '</div>';
|
|
||||||
el += '<div class="body">';
|
|
||||||
el += markdown(page.license || theme.article.license);
|
|
||||||
el += '</div>';
|
|
||||||
el += '</section>';
|
|
||||||
}
|
}
|
||||||
|
} else if (page.layout == 'wiki' && page.wiki) {
|
||||||
|
let proj = theme.wiki.tree[page.wiki]
|
||||||
|
if (page.license != null) {
|
||||||
|
license = markdown(page.license || theme.article.license)
|
||||||
|
} else if (proj?.license != null) {
|
||||||
|
license = markdown(proj.license || theme.article.license)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (license.length > 0) {
|
||||||
|
el += `
|
||||||
|
<section id="license">
|
||||||
|
<div class="header"><span>${__('meta.license')}</span></div>
|
||||||
|
<div class="body">${license}</div>
|
||||||
|
</section>
|
||||||
|
`
|
||||||
|
}
|
||||||
|
|
||||||
if (theme.article.share && page.share != false) {
|
var showSharePlugin = false
|
||||||
el += '<section id="share">';
|
if (page.layout == 'post') {
|
||||||
el += '<div class="header">';
|
showSharePlugin = page.share != false
|
||||||
el += '<span>' + __('meta.share') + '</span>';
|
} else if (page.layout == 'wiki' && page.wiki) {
|
||||||
el += '</div>';
|
let proj = theme.wiki.tree[page.wiki]
|
||||||
el += '<div class="body">';
|
if (page.share != null) {
|
||||||
el += '<div class="link"><input class="copy-area" readonly="true" id="copy-link" value="' + page.permalink + '" /></div>';
|
showSharePlugin = page.share == true
|
||||||
el += '<div class="social-wrap dis-select">';
|
} else if (proj != null) {
|
||||||
|
showSharePlugin = proj.share == true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (theme.article.share && showSharePlugin) {
|
||||||
|
function socialButtons() {
|
||||||
|
var el = ''
|
||||||
theme.article.share.forEach((item, i) => {
|
theme.article.share.forEach((item, i) => {
|
||||||
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
|
if (['wechat', 'weibo', 'email', 'link'].includes(item)) {
|
||||||
el += '<a class="social share-item ' + item + '"';
|
el += '<a class="social share-item ' + item + '"';
|
||||||
|
@ -96,15 +115,29 @@ function layoutDiv() {
|
||||||
el += '</a>';
|
el += '</a>';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
el += '</div>';
|
return el;
|
||||||
if (theme.article.share.includes('wechat')) {
|
|
||||||
el += '<div class="qrcode" id="qrcode-wechat" style="visibility:hidden;height:0">';
|
|
||||||
el += '<img src="https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=' + page.permalink + '"/>';
|
|
||||||
el += '</div>';
|
|
||||||
}
|
|
||||||
el += '</div>';
|
|
||||||
el += '</section>';
|
|
||||||
}
|
}
|
||||||
|
function qrcode() {
|
||||||
|
if (theme.article.share.includes('wechat')) {
|
||||||
|
return `
|
||||||
|
<div class="qrcode" id="qrcode-wechat" style="visibility:hidden;height:0">
|
||||||
|
<img src="https://api.qrserver.com/v1/create-qr-code/?size=256x256&data=${page.permalink}"/>
|
||||||
|
</div>
|
||||||
|
`
|
||||||
|
} else {
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
el += `
|
||||||
|
<section id="share">
|
||||||
|
<div class="header"><span>${__('meta.share')}</span></div>
|
||||||
|
<div class="body">
|
||||||
|
<div class="link"><input class="copy-area" readonly="true" id="copy-link" value="${page.permalink}" /></div>
|
||||||
|
<div class="social-wrap dis-select">${socialButtons()}</div>
|
||||||
|
${qrcode()}
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
el += '</div>';
|
el += '</div>';
|
||||||
|
|
Loading…
Reference in New Issue