Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加几个新功能 #62

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ hexo deploy
主题下的 _config.yml 文件

```
# Top menu
menu:
# About: /about

# Camera icon for website
# 填写 baseurl 开启主页小相机,也可以在博客根目录的 _config.yml 文件末尾添加
baseurl:
Expand All @@ -43,8 +47,14 @@ date_format: YYYY 年 MM 月 DD 日
# Comment.
comments:
# Disqus comment
# 填写 disqus_shortname 即可使用 disqus
disqus_shortname:
disqus:
enable: false
disqus_shortname:
valine:
enable: true
appId: # leancloud application app id
appKey: # leancloud application app key
placeholder: random # Placeholder. Set to random string if you want to have random placeholders(一言api).

# Google Analytics Tracking ID
# 填写谷歌分析跟踪 ID,使用谷歌分析应用
Expand All @@ -70,6 +80,12 @@ image_viewer: true
# 也许在之后的更新中会支持更多目录样式
toc:
enable: true

# using highlight.js to show the code
# https://highlightjs.org/
hljs:
enable: true
theme: xcode
```

## 文章格式
Expand All @@ -93,6 +109,16 @@ date: <文章日期> [YYYY-MM-DD]

## CHANGELOG

20240121 @timlzh
- 增加暗黑模式开关
- 页脚以及备案信息显示
- Tags/Categories页面生成

20231102 @timlzh
- 增加highlight.js代码高亮
- 增加顶部导航栏功能
- 增加valine评论系统

20220202 @zchen9
- 调整 toc 样式
- 修复 Bootstrap CDN 404 问题
Expand Down
32 changes: 30 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Top menu
menu:
# Tags: /tags
# Categories: /categories

# Site Icon
favicon:

# Camera icon for website
baseurl:

Expand All @@ -10,8 +18,15 @@ date_format: YYYY 年 MM 月 DD 日
# Comment.
comments:
# Disqus comment
disqus_shortname:

disqus:
enable: false
disqus_shortname:
valine:
enable: true
appId: appid
appKey: appkey
placeholder: random # Placeholder. Set to random string if you want to have random placeholders(一言api).

# Google Analytics Tracking ID
google_analytics:

Expand All @@ -29,3 +44,16 @@ image_viewer: true
# Maybe support more toc style in future.
toc:
enable: true

footer:
enable: true
beian: 浙ICP备2022036129号-2
# content: 本站采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh">CC BY-NC-SA 4.0</a> 协议进行许可

# using highlight.js to show the code
# https://highlightjs.org/
hljs:
enable: true
theme:
light: github
dark: github-dark-dimmed
25 changes: 22 additions & 3 deletions layout/_partial/article-full.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
<%
var title = item.title || theme.default_post_title || "Untitled";
var mainTitle = title.split(" | ")[0];
var subTitle = title.split(" | ")[1];
%>


<section class="article-container">
<!-- Back Home -->
<%- partial('_partial/backhome') %>
Expand All @@ -9,8 +16,12 @@
<div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
<div class="post-heading">
<h1>
<%- item.title || theme.default_post_title || "Untitled" %>
<%- mainTitle %>
</h1>
<div class="subheading">
<%- subTitle %>
</div>
<hr>
</div>
</div>
</div>
Expand Down Expand Up @@ -54,7 +65,15 @@
</section>

<!-- Image viewer-->
<%- partial('_partial/img-viewer') %>
<% if(!(item.img_viewer==false)) { %>
<%- partial('_partial/img-viewer') %>
<% } %>

<!-- TOC -->
<%- partial("_partial/toc", {post: item}) %>
<!-- <%- partial("_partial/toc", {post: item}) %> -->

<% if(theme.hljs.enable){ %>
<script>
hljs.highlightAll();
</script>
<% } %>
19 changes: 16 additions & 3 deletions layout/_partial/article-index.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
<div class="post-preview">
<a href="<%- config.root %><%- item.path %>">
<h2 class="post-title">
<%- item.title || theme.default_post_title || "Untitled" %>
</h2>
<div class="post-title">
<!-- <%- item.title || theme.default_post_title || "Untitled" %> -->
<%
var title = item.title || theme.default_post_title || "Untitled";
var mainTitle = title.split(" | ")[0];
var subTitle = title.split(" | ")[1];
%>
<div class="post-maintitle">
<%- mainTitle %>
</div>
<div class="post-subtitle">
<!-- <%- item.excerpt %> -->
<%- subTitle %>
</div>
</div>

<%- item.excerpt %>
</a>
</div>
17 changes: 14 additions & 3 deletions layout/_partial/backhome.ejs
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
<a class="nav-back" href="<%- config.root %>">
<i class="fa fa-puzzle-piece"></i>
</a>
<!-- <a class="nav-back" href="javascript:back()">
<i class="fa fa-arrow-left"></i>
</a>

<script>
function back() {
var home = '<%- config.root || '/' %>'
if (document.referrer && document.referrer.indexOf(home) > -1) {
window.history.back();
} else {
window.location.href = home;
}
}
</script> -->
83 changes: 80 additions & 3 deletions layout/_partial/comment.ejs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- Disqus Comments -->
<% if (theme.comments && theme.comments.disqus_shortname){ %>
<% if (theme.comments && theme.comments.disqus.enable && theme.comments.disqus.disqus_shortname){ %>
<div id="disqus_thread" class="comment"></div>
<script>
var disqus_shortname = '<%= theme.comments.disqus_shortname %>';
var disqus_shortname = '<%= theme.comments.disqus.disqus_shortname %>';
var disqus_website = '<%= theme.baseurl %>';
var disqus_config = function () {
this.page.url = disqus_website;
Expand All @@ -17,4 +17,81 @@
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by
Disqus.</a></noscript>
<% } %>
<!-- Valine Comments -->
<% } else if(theme.comments && theme.comments.valine.enable){ %>
<div id="vcomments" class="comment"></div>
<script>
new Valine({
el: '.comment',
appId: '<%= theme.comments.valine.appId %>',
appKey: '<%= theme.comments.valine.appKey %>',
placeholder: '<%= theme.comments.valine.placeholder %>',
avatar: '',
enableQQ: true,
emojiCDN: '//i0.hdslb.com/bfs/emote/',
// 表情title和图片映射
emojiMaps: {
"tv_doge": "6ea59c827c414b4a2955fe79e0f6fd3dcd515e24.png",
"tv_亲亲": "a8111ad55953ef5e3be3327ef94eb4a39d535d06.png",
"tv_偷笑": "bb690d4107620f1c15cff29509db529a73aee261.png",
"tv_再见": "180129b8ea851044ce71caf55cc8ce44bd4a4fc8.png",
"tv_冷漠": "b9cbc755c2b3ee43be07ca13de84e5b699a3f101.png",
"tv_发怒": "34ba3cd204d5b05fec70ce08fa9fa0dd612409ff.png",
"tv_发财": "34db290afd2963723c6eb3c4560667db7253a21a.png",
"tv_可爱": "9e55fd9b500ac4b96613539f1ce2f9499e314ed9.png",
"tv_吐血": "09dd16a7aa59b77baa1155d47484409624470c77.png",
"tv_呆": "fe1179ebaa191569b0d31cecafe7a2cd1c951c9d.png",
"tv_呕吐": "9f996894a39e282ccf5e66856af49483f81870f3.png",
"tv_困": "241ee304e44c0af029adceb294399391e4737ef2.png",
"tv_坏笑": "1f0b87f731a671079842116e0991c91c2c88645a.png",
"tv_大佬": "093c1e2c490161aca397afc45573c877cdead616.png",
"tv_大哭": "23269aeb35f99daee28dda129676f6e9ea87934f.png",
"tv_委屈": "d04dba7b5465779e9755d2ab6f0a897b9b33bb77.png",
"tv_害羞": "a37683fb5642fa3ddfc7f4e5525fd13e42a2bdb1.png",
"tv_尴尬": "7cfa62dafc59798a3d3fb262d421eeeff166cfa4.png",
"tv_微笑": "70dc5c7b56f93eb61bddba11e28fb1d18fddcd4c.png",
"tv_思考": "90cf159733e558137ed20aa04d09964436f618a1.png",
"tv_惊吓": "0d15c7e2ee58e935adc6a7193ee042388adc22af.png",
"tv_打脸": "56ab10b624063e966bfcb76ea5dc4794d87dfd47.png",
"tv_抓狂": "fe31c08edad661d63762b04e17b8d5ae3c71a757.png",
"tv_抠鼻": "c666f55e88d471e51bbd9fab9bb308110824a6eb.png",
"tv_斜眼笑": "911f987aa8bc1bee12d52aafe62bc41ef4474e6c.png",
"tv_无奈": "ea8ed89ee9878f2fece2dda0ea8a5dbfe21b5751.png",
"tv_晕": "5443c22b4d07fb1907ccc610c8e6db254f2461b7.png",
"tv_流汗": "cead1c351ab8d79e9f369605beb90148db0fbed3.png",
"tv_流泪": "7e71cde7858f0cd50d74b0264aa26db612a8a167.png",
"tv_流鼻血": "c32d39db2737f89b904ca32700d140a9241b0767.png",
"tv_点赞": "f85c354995bd99e28fc76c869bfe42ba6438eff4.png",
"tv_生气": "26702dcafdab5e8225b43ffd23c94ac1ff932654.png",
"tv_生病": "8b0ec90e6b86771092a498c54f09fc94621c1900.png",
"tv_疑问": "0793d949b18d7be716078349c202c15ff166f314.png",
"tv_白眼": "c1d59f439e379ee50eef488bcb5e5378e5044ea4.png",
"tv_皱眉": "72ccad6679fea0d14cce648b4d818e09b8ffea2d.png",
"tv_目瞪口呆": "0b8cb81a68de5d5365212c99375e7ace3e7891b7.png",
"tv_睡着": "8b196675b53af58264f383c50ad0945048290b33.png",
"tv_笑哭": "1abc628f6d4f4caf9d0e7800878f4697abbc8273.png",
"tv_腼腆": "89712c0d4af73e67f89e35cbc518420380a7f6f4.png",
"tv_色": "61822c7e9aae5da76475e7892534545336b23a6f.png",
"tv_调侃": "4bc022533ef31544ca0d72c12c808cf4a1cce3e3.png",
"tv_调皮": "b9c41de8e82dd7a8515ae5e3cb63e898bf245186.png",
"tv_鄙视": "6e72339f346a692a495b123174b49e4e8e781303.png",
"tv_闭嘴": "c9e990da7f6e93975e25fd8b70e2e290aa4086ef.png",
"tv_难过": "87f46748d3f142ebc6586ff58860d0e2fc8263ba.png",
"tv_馋": "fc7e829b845c43c623c8b490ee3602b7f0e76a31.png",
"tv_鬼脸": "0ffbbddf8a94d124ca2f54b360bbc04feb6bbfea.png",
"tv_黑人问号": "45821a01f51bc867da9edbaa2e070410819a95b2.png",
"tv_鼓掌": "1d21793f96ef4e6f48b23e53e3b9e42da833a0f6.png"
// ... 更多表情
}
})
if('<%= theme.comments.valine.placeholder %>' == 'random'){
var veditor = document.getElementById("veditor");
fetch('https://v1.hitokoto.cn')
.then(response => response.json())
.then(data => {
veditor.placeholder = '『' + data.hitokoto + '』' + '\n\n\n' + 'From ' + data.from;
})
.catch(console.error)
}
</script>
<% } %>
Empty file added layout/_partial/darkmode.ejs
Empty file.
12 changes: 12 additions & 0 deletions layout/_partial/footer.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<% if (theme.footer && theme.footer.enable) { %>
<% if (theme.footer.content) { %>
<div class="content">
<%- theme.footer.content %>
</div>
<% } %>
<% if (theme.footer.beian) { %>
<div class="beian">
<a href="https://beian.miit.gov.cn/" target="_blank"><%- theme.footer.beian %></a>
</div>
<% } %>
<% } %>
23 changes: 23 additions & 0 deletions layout/_partial/go-top.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<a class="go-top">
<i class="fa fa-arrow-up"></i>
</a>

<script type="text/javascript">
if ($(window).scrollTop() <= 100) {
$(".go-top").hide();
}
$(function () {
$(window).scroll(function () {
if ($(window).scrollTop() > 100) {
$(".go-top").fadeIn(500);
} else {
$(".go-top").fadeOut(500);
}
});
$(".go-top").click(function () {
$('body,html').animate({scrollTop: 0}, 500);
return false;
});
});
</script>
Loading