主题页面精简

This commit is contained in:
结发受长生 2019-07-08 09:45:27 +08:00
parent d230b5a85d
commit 6689e4d5c1
11 changed files with 59 additions and 172 deletions

View File

@ -65,40 +65,16 @@ toc_empty_wording: 目录,不存在的…
# 是否有快速回到顶部的按钮
top: true
# Miscellaneous
baidu_analytics: ''
google_analytics: ''
# 站点图标
favicon: /favicon.ico
#你的头像url
#头像url
avatar: https://cdn.colorfulsweet.site/resources/avatar.jpg
#是否开启分享
share_jia: true
share_enable: true
#评论1、畅言2、Disqus3、Gitment
#不需要使用某项直接设置值为false或注释掉
#具体请参考wikihttps://github.com/litten/hexo-theme-yilia/wiki/
#1、畅言
changyan_appid: false
changyan_conf: false
#2、Disqus 在hexo根目录的config里也有disqus_shortname字段优先使用yilia的
disqus: false
#3、gitalk
gitalk:
enable: false
ClientID: 90e8f648da2a669f7975
ClientSecret: 7d2b602616387748ef0df10f7a8a626bdfd1034c
repo: hexo_blog
githubID: sookie2010
adminUser: sookie2010
distractionFreeMode: false
#4、Valine
#评论 Valine
valine:
enable: true
appId: 40jq6uO51rpVT4PEEcayYkda-gzGzoHsz

View File

@ -7,25 +7,9 @@ window.themeConfig = {
isCategory: <%=is_category()%>, // 是否为分类页面
pageid: <%-page.pageid ? `"${page.pageid}"` : 'undefined'%>, // 页面标识, 用于个性化页面开发
toc_hide_index: <%=theme.toc_hide_index%>, // 目录序号
root: "<%=config.root%>", // 资源根路径
pictureCdn: "<%=config.picture_cdn%>" // 图片存储仓库地址
root: '<%=config.root%>', // 资源根路径
baseUrl: '<%=config.url%>',
pictureCdn: '<%=config.picture_cdn%>' // 图片存储仓库地址
}
</script>
<%- partial('script') %>
<% if(theme.gitalk.enable && is_post()) { %>
<link rel="stylesheet" type="text/css" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
<script>
(function(Gitalk){
new Gitalk({
clientID: '<%=theme.gitalk.ClientID%>',
clientSecret: '<%=theme.gitalk.ClientSecret%>',
repo: '<%=theme.gitalk.repo%>',
owner: '<%=theme.gitalk.githubID%>',
admin: ['<%=theme.gitalk.adminUser%>'],
id: decodeURI(location.pathname),
distractionFreeMode: <%=theme.gitalk.distractionFreeMode%>
}).render('comments')
})(Gitalk)
</script>
<% } %>
<%- partial('script') %>

View File

@ -79,7 +79,7 @@
<a class="article-more-a" href="<%- url_for(post.path) %>"><%= __('show_full_text') %> >></a>
</p>
<% } %>
<% if (!param.index && theme.share_jia){ %>
<% if (!param.index && theme.share_enable){ %>
<%- partial('post/share') %>
<% } %>
<div class="clearfix"></div>
@ -90,33 +90,6 @@
<%- partial('post/nav') %>
<% } %>
<% if (!param.index && post.comments){ %>
<% if (theme.changyan_appid && theme.changyan_conf){ %>
<%- partial('post/changyan', {
key: post.slug,
title: post.title,
url: config.url+url_for(post.path)
}) %>
<% } %>
<% if (theme.disqus || config.disqus_shortname){ %>
<section id="comments">
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = '<%= theme.disqus || config.disqus_shortname %>'; // required: replace example with your forum shortname
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</section>
<% }
if(theme.gitalk.enable || theme.valine.enable){ %>
<% if (!param.index && post.comments && theme.valine.enable){ %>
<div id="comments"></div>
<% } %>
<% } %>

View File

@ -1,11 +0,0 @@
<% if (theme.baidu_analytics){ %>
<script>
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?<%= theme.baidu_analytics %>";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<% } %>

View File

@ -1,14 +0,0 @@
<% if (theme.google_analytics){ %>
<!-- Google Analytics -->
<script type="text/javascript">
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '<%= theme.google_analytics %>', 'auto');
ga('send', 'pageview');
</script>
<!-- End Google Analytics -->
<% } %>

View File

@ -22,12 +22,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<%- open_graph({twitter_id: theme.twitter, google_plus: theme.google_plus, fb_admins: theme.fb_admins, fb_app_id: theme.fb_app_id}) %>
<% if (theme.rss){ %>
<link rel="alternative" href="<%- theme.rss %>" title="<%= config.title %>" type="application/atom+xml">
<link rel="alternative" href="<%- url_for(theme.rss) %>" title="<%= config.title %>" type="application/atom+xml">
<% } %>
<% if (theme.favicon){ %>
<link rel="icon" href="<%- theme.favicon %>">
<link rel="icon" href="<%- url_for(theme.favicon) %>">
<% } %>
<%- partial('css') %>
<%- partial('google-analytics') %>
<%- partial('baidu-analytics') %>
</head>

View File

@ -20,7 +20,7 @@
</nav>
<nav id="sub-nav">
<% if (theme.rss){ %>
<a id="nav-rss-link" class="nav-icon" href="<%- theme.rss %>" title="RSS Feed"></a>
<a id="nav-rss-link" class="nav-icon" href="<%- url_for(theme.rss) %>" title="RSS Feed"></a>
<% } %>
<a id="nav-search-btn" class="nav-icon" title="Search"></a>
</nav>

View File

@ -1,9 +0,0 @@
<div id="SOHUCS" sid="<%=key%>" ></div>
<script charset="utf-8" type="text/javascript" src="//changyan.sohu.com/upload/changyan.js" ></script>
<script type="text/javascript">
window.changyan.api.config({
appid: "<%=theme.changyan_appid%>",
conf: "<%=theme.changyan_conf%>"
});
</script>
</script>

View File

@ -1,18 +0,0 @@
<div class="duoshuo">
<!-- 多说评论框 start -->
<div class="ds-thread" data-thread-key="<%=key%>" data-title="<%=title%>" data-url="<%=url%>"></div>
<!-- 多说评论框 end -->
<!-- 多说公共JS代码 start (一个网页只需插入一次) -->
<script type="text/javascript">
var duoshuoQuery = {short_name:"<%=theme.duoshuo%>"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- 多说公共JS代码 end -->
</div>

View File

@ -37,11 +37,11 @@
</div>
<div class="page-modal wx-share js-wx-box">
<a class="close js-modal-close" href="javascript:;"><i class="icon icon-close"></i></a>
<p>扫一扫,分享到微信</p>
<div class="wx-qrcode" title="微信分享二维码">
<canvas class="qrcode-canvas" style="height:150px;width:150px;"></canvas>
</div>
<a class="close js-modal-close" href="javascript:;"><i class="icon icon-close"></i></a>
<p>扫一扫,分享到微信</p>
<div class="wx-qrcode" title="微信分享二维码">
<canvas class="qrcode-canvas" style="height:150px;width:150px;"></canvas>
</div>
</div>
<div class="mask js-mask"></div>

View File

@ -1,16 +1,7 @@
import QRious from 'qrious'
function generate(url, opts) {
var url = url.replace(/<%-sUrl%>/g, encodeURIComponent(opts.sUrl))
.replace(/<%-sTitle%>/g, opts.sTitle)
.replace(/<%-sDesc%>/g, opts.sDesc)
.replace(/<%-sPic%>/g, encodeURIComponent(opts.sPic))
window.open(url)
}
var qrcodeInit = false
function showWX() {
function showWXModal() {
let wx = document.querySelector('.js-wx-box')
let mask = document.querySelector('.mask')
if(!qrcodeInit) {
@ -24,30 +15,45 @@ function showWX() {
mask.classList.add('in')
}
function hideWX() {
let wx = document.querySelector('.js-wx-box')
function hideModal() {
let modals = document.querySelectorAll('.page-modal')
let mask = document.querySelector('.mask')
wx.classList.remove('in', 'ready')
Array.prototype.forEach.call(modals, modal => {
modal.classList.remove('in', 'ready')
})
mask.classList.remove('in')
}
function handleClick(type, opts) {
if (type === 'weibo') {
generate('http://service.weibo.com/share/share.php?url=<%-sUrl%>&title=<%-sTitle%>&pic=<%-sPic%>', opts)
} else if (type === 'qq') {
generate('http://connect.qq.com/widget/shareqq/index.html?url=<%-sUrl%>&title=<%-sTitle%>&source=<%-sDesc%>', opts)
} else if (type === 'douban') {
generate('https://www.douban.com/share/service?image=<%-sPic%>&href=<%-sUrl%>&name=<%-sTitle%>&text=<%-sDesc%>', opts)
} else if (type === 'qzone') {
generate('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=<%-sUrl%>&title=<%-sTitle%>&pics=<%-sPic%>&summary=<%-sDesc%>', opts)
} else if (type === 'facebook') {
generate('https://www.facebook.com/sharer/sharer.php?u=<%-sUrl%>', opts)
} else if (type === 'twitter') {
generate('https://twitter.com/intent/tweet?text=<%-sTitle%>&url=<%-sUrl%>&via=<%-config.url%>', opts)
} else if (type === 'google') {
generate('https://plus.google.com/share?url=<%-sUrl%>', opts)
} else if (type === 'weixin') {
showWX()
let url = null
switch(type) {
case 'weibo' :
url = `http://service.weibo.com/share/share.php?url=${opts.sUrl}&title=${opts.sTitle}&pic=${opts.sPic}`
break
case 'qq' :
url = `http://connect.qq.com/widget/shareqq/index.html?url=${opts.sUrl}&title=${opts.sTitle}&source=${opts.sDesc}`
break
case 'douban' :
url = `https://www.douban.com/share/service?image=${opts.sPic}&href=${opts.sUrl}&name=${opts.sTitle}&text=${opts.sDesc}`
break
case 'qzone' :
url = `http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=${opts.sUrl}&title=${opts.sTitle}&pics=${opts.sPic}&summary=${opts.sDesc}`
break
case 'facebook' :
url = `https://www.facebook.com/sharer/sharer.php?u=${opts.sUrl}`
break
case 'twitter' :
url = `https://twitter.com/intent/tweet?text=${opts.sTitle}&url=${opts.sUrl}&via=${themeConfig.baseUrl}`
break
case 'google' :
url = `https://plus.google.com/share?url=${opts.sUrl}`
break
case 'weixin' :
showWXModal()
break
}
if(url) {
window.open(url)
}
}
@ -66,15 +72,17 @@ let init = function() {
$em.onclick = (e) => {
let type = $em.getAttribute('data-type')
handleClick(type, {
sUrl: sUrl,
sPic: sPic,
sUrl: encodeURIComponent(sUrl),
sPic: encodeURIComponent(sPic),
sTitle: sTitle,
sDesc: sTitle
})
}
})
document.querySelector('.mask').addEventListener('click', hideWX)
document.querySelector('.js-modal-close').addEventListener('click', hideWX)
document.querySelector('.mask').addEventListener('click', hideModal)
Array.prototype.forEach.call(document.querySelectorAll('.js-modal-close'), modalClose => {
modalClose.addEventListener('click', hideModal)
})
}
export default { init }