parent
1d9ffe580d
commit
923ae1a61b
19 changed files with 529 additions and 282 deletions
@ -0,0 +1,15 @@ |
||||
<% if (theme.comments.valine && theme.comments.valine.appId){ %> |
||||
<div class="new-meta-item comments-count"> |
||||
<% |
||||
var path = post.path || page.path; |
||||
if (path.length > 9 && (path.substring(path.length - 10) == 'index.html')) { |
||||
path = path.substring(0, path.length - 10); |
||||
} |
||||
%> |
||||
<a href="<%- url_for(path) %>#comments"> |
||||
<i class="<%- theme.meta.valinecount.icon %> fa-fw"></i> |
||||
<span class="valine-comment-count" data-xid="<%- url_for(path) %>">0</span> |
||||
<span class="leancloud-comments-count"> <%- theme.meta.valinecount.desc %></span> |
||||
</a> |
||||
</div> |
||||
<% } %> |
@ -1,17 +1,18 @@ |
||||
<% if (page.cover == true) { %> |
||||
<div class="cover-wrapper"> |
||||
<% if (is_home() && page.prev == 0 && theme.cover.scheme == 'docs') { %> |
||||
<cover class='cover <%- page.layout %> full'> |
||||
<%- partial('../_cover/index') %> |
||||
<div class="scroll-down"><i class="fa fa-chevron-down scroll-down-effects"></i></div> |
||||
</cover> |
||||
<% } else { %> |
||||
<cover class='cover <%- page.layout %> half'> |
||||
<%- partial('../_cover/index') %> |
||||
</cover> |
||||
<% } %> |
||||
<%- partial('header', null, {cache: false, path: path}) %> |
||||
</div> |
||||
<% } else { %> |
||||
<% |
||||
var enableCover = false; // 封面是否开启 |
||||
if(theme.cover && theme.cover.scheme) { |
||||
enableCover = true; |
||||
} |
||||
%> |
||||
|
||||
<% if (enableCover) { %> |
||||
<div class="cover-wrapper"> |
||||
<cover class='cover <%- page.layout %>' style="display: none;"> |
||||
<%- partial('../_cover/index') %> |
||||
<div class="scroll-down" style="display: none;"><i class="fa fa-chevron-down scroll-down-effects"></i></div> |
||||
</cover> |
||||
<%- partial('header', null, {cache: false, path: path}) %> |
||||
</div> |
||||
<% } else { %> |
||||
<%- partial('header', null, {cache: false, path: path}) %> |
||||
<% } %> |
||||
|
@ -1,54 +1,53 @@ |
||||
<script src="<%- theme.plugins.clipboard %>"></script> |
||||
<script> |
||||
function wait(callback, seconds) { |
||||
var timelag = null; |
||||
timelag = window.setTimeout(callback, seconds); |
||||
} |
||||
!function (e, t, a) { |
||||
var initCopyCode = function(){ |
||||
var copyHtml = ''; |
||||
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">'; |
||||
copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>'; |
||||
copyHtml += '</button>'; |
||||
$(".highlight .code pre").before(copyHtml); |
||||
$(".article pre code").before(copyHtml); |
||||
var clipboard = new ClipboardJS('.btn-copy', { |
||||
target: function(trigger) { |
||||
return trigger.nextElementSibling; |
||||
} |
||||
}); |
||||
clipboard.on('success', function(e) { |
||||
let $btn = $(e.trigger); |
||||
$btn.addClass('copied'); |
||||
let $icon = $($btn.find('i')); |
||||
$icon.removeClass('fa-copy'); |
||||
$icon.addClass('fa-check-circle'); |
||||
let $span = $($btn.find('span')); |
||||
$span[0].innerText = 'COPIED'; |
||||
|
||||
wait(function () { // 等待两秒钟后恢复 |
||||
$icon.removeClass('fa-check-circle'); |
||||
$icon.addClass('fa-copy'); |
||||
$span[0].innerText = 'COPY'; |
||||
}, 2000); |
||||
}); |
||||
clipboard.on('error', function(e) { |
||||
e.clearSelection(); |
||||
let $btn = $(e.trigger); |
||||
$btn.addClass('copy-failed'); |
||||
let $icon = $($btn.find('i')); |
||||
$icon.removeClass('fa-copy'); |
||||
$icon.addClass('fa-times-circle'); |
||||
let $span = $($btn.find('span')); |
||||
$span[0].innerText = 'COPY FAILED'; |
||||
|
||||
wait(function () { // 等待两秒钟后恢复 |
||||
$icon.removeClass('fa-times-circle'); |
||||
$icon.addClass('fa-copy'); |
||||
$span[0].innerText = 'COPY'; |
||||
}, 2000); |
||||
}); |
||||
function wait(callback, seconds) { |
||||
var timelag = null; |
||||
timelag = window.setTimeout(callback, seconds) |
||||
} |
||||
initCopyCode(); |
||||
}(window, document); |
||||
</script> |
||||
|
||||
function pjax_initCopyCode() { |
||||
var copyHtml = ''; |
||||
copyHtml += '<button class="btn-copy" data-clipboard-snippet="">'; |
||||
copyHtml += '<i class="fas fa-copy"></i><span>COPY</span>'; |
||||
copyHtml += '</button>'; |
||||
$(".highlight .code pre").before(copyHtml); |
||||
$(".article pre code").before(copyHtml); |
||||
var clipboard = new ClipboardJS('.btn-copy', { |
||||
target: function (trigger) { |
||||
return trigger.nextElementSibling |
||||
} |
||||
}); |
||||
clipboard.on('success', function (e) { |
||||
let $btn = $(e.trigger); |
||||
$btn.addClass('copied'); |
||||
let $icon = $($btn.find('i')); |
||||
$icon.removeClass('fa-copy'); |
||||
$icon.addClass('fa-check-circle'); |
||||
let $span = $($btn.find('span')); |
||||
$span[0].innerText = 'COPIED'; |
||||
wait(function () { |
||||
$icon.removeClass('fa-check-circle'); |
||||
$icon.addClass('fa-copy'); |
||||
$span[0].innerText = 'COPY' |
||||
}, 2000) |
||||
}); |
||||
clipboard.on('error', function (e) { |
||||
e.clearSelection(); |
||||
let $btn = $(e.trigger); |
||||
$btn.addClass('copy-failed'); |
||||
let $icon = $($btn.find('i')); |
||||
$icon.removeClass('fa-copy'); |
||||
$icon.addClass('fa-times-circle'); |
||||
let $span = $($btn.find('span')); |
||||
$span[0].innerText = 'COPY FAILED'; |
||||
wait(function () { |
||||
$icon.removeClass('fa-times-circle'); |
||||
$icon.addClass('fa-copy'); |
||||
$span[0].innerText = 'COPY' |
||||
}, 2000) |
||||
}) |
||||
} |
||||
$(function () { |
||||
pjax_initCopyCode() |
||||
}); |
||||
</script> |
@ -0,0 +1,78 @@ |
||||
<!--此文件用来存放一些不方便取值的变量--> |
||||
<!--思路大概是将值藏到重加载的区域内--> |
||||
|
||||
<% |
||||
var changeValinePath = 'none'; // 自定义的 valine 评论路径 |
||||
var changeValinePlaceholder = 'none'; // 自定义的 valine 评论描述 |
||||
var ispage = false; // 一二级导航栏切换控制 |
||||
var postTitle = ''; // 当前文章标题,用于二级导航栏赋值 |
||||
var enableCover = false; // 封面是否开启 |
||||
var frontMatterCover = 'none'; // 封面控制 |
||||
|
||||
var enableValine = false; |
||||
if (theme.comments && page && page.comments == true && theme.comments.valine && theme.comments.valine.appId) { |
||||
enableValine = true; |
||||
} |
||||
|
||||
if (page && page.comments == true) { |
||||
if (enableValine && page.valine && page.valine.path) { |
||||
changeValinePath = page.valine.path; |
||||
} |
||||
if (enableValine && page.valine && page.valine.placeholder) { |
||||
changeValinePlaceholder = page.valine.placeholder; |
||||
} |
||||
} |
||||
|
||||
if(theme.cover && theme.cover.scheme) { |
||||
enableCover = true; |
||||
} |
||||
|
||||
if (enableCover && page && page.cover) { |
||||
frontMatterCover = page.cover; |
||||
if (is_home() && page.prev == 0 && theme.cover.scheme == 'docs') { |
||||
frontMatterCover = 'docs'; |
||||
} else { |
||||
frontMatterCover = 'blog'; |
||||
} |
||||
} |
||||
|
||||
if (page && page.layout == 'post' && page.title) { |
||||
ispage = true; |
||||
postTitle = page.title; |
||||
} |
||||
|
||||
%> |
||||
|
||||
<div id="pjax-data" style="display: none"> |
||||
<div id="pjax-ispage"><%=ispage%></div> |
||||
<div id="pjax-pageTitle"><%=postTitle%></div> |
||||
<div id="pjax-enable-cover"><%=enableCover%></div> |
||||
<% if (enableValine){ %> |
||||
<div id="valine-path"><%=changeValinePath%></div> |
||||
<div id="valine-placeholder"><%=changeValinePlaceholder%></div> |
||||
<% } %> |
||||
</div> |
||||
|
||||
<% if (enableCover) { %> |
||||
<script> |
||||
// 处理封面 此时 jquery 还没加载 |
||||
if("<%=frontMatterCover%>" == "none") { // 移除封面 |
||||
document.getElementsByClassName('cover')[0].style.display = "none"; |
||||
document.getElementsByClassName('l_body')[0].classList.add("nocover"); |
||||
document.getElementsByClassName('l_header','cover-wrapper')[0].classList.add("show"); |
||||
} else { |
||||
if("<%=frontMatterCover%>" == "blog") { // 半屏 |
||||
document.getElementsByClassName('cover')[0].classList.remove("full"); |
||||
document.getElementsByClassName('cover')[0].classList.add("half"); |
||||
document.getElementsByClassName('scroll-down')[0].style.display = "none"; |
||||
} else if("<%=frontMatterCover%>" == "docs") { // 全屏 |
||||
document.getElementsByClassName('cover')[0].classList.remove("half"); |
||||
document.getElementsByClassName('cover')[0].classList.add("full"); |
||||
document.getElementsByClassName('scroll-down')[0].style.display = ""; |
||||
} |
||||
document.getElementsByClassName('cover')[0].style.display = ""; |
||||
document.getElementsByClassName('l_body','show')[0].classList.remove("nocover"); |
||||
document.getElementsByClassName('l_header','cover-wrapper')[0].classList.remove("show"); |
||||
} |
||||
</script> |
||||
<% } %> |
Loading…
Reference in new issue