Skip to content

Commit

Permalink
Merge pull request #285 from Stark-X/master
Browse files Browse the repository at this point in the history
packag version upgrade and bug fixing
  • Loading branch information
LolipopJ authored May 22, 2021
2 parents dbc7f68 + 4b63790 commit c79ede0
Show file tree
Hide file tree
Showing 32 changed files with 5,840 additions and 12,979 deletions.
5 changes: 5 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"presets": [
"@babel/preset-env"
]
}
28 changes: 27 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,33 @@ node_modules
_config_.yml
_config__.yml
.jsbeautifyrc

# Created by https://www.gitignore.io/api/vim

### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]

# Session
Session.vim

# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~


# End of https://www.gitignore.io/api/vim

*.iml
*.ipr
*.iws
*.iml
*.iml

134 changes: 6 additions & 128 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ hexo-theme-archer
- 2018.08.26 - 『添加 i18n 支持』
- 2020.03.02 - 『添加 Gitalk评论 支持』
- 2020.03.04 - 『添加 utteranc评论 支持』
- 2020.01.26 - 『更新使用的 nodejs,以及相关依赖包的版本』
- 2020.02.03 - 『添加“文章时效性”提示』

## 说明

Expand Down Expand Up @@ -94,7 +96,7 @@ jsonContent:
- [启用 rss 订阅](https://github.com/fi3ework/hexo-theme-archer/wiki/%E5%90%AF%E7%94%A8rss)
- [自定义单独文章页头图](https://github.com/fi3ework/hexo-theme-archer/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%87%E7%AB%A0%E9%A1%B5%E5%A4%B4%E5%9B%BE)
- [将 Unsplash 的随机图片作为头图](https://github.com/fi3ework/hexo-theme-archer/wiki/%E5%B0%86-Unsplash-%E9%9A%8F%E6%9C%BA%E5%9B%BE%E7%89%87%E4%BD%9C%E4%B8%BA%E5%A4%B4%E5%9B%BE)
- [自定义文章在首页的摘要](https://github.com/fi3ework/hexo-theme-archer/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%87%E7%AB%A0%E5%9C%A8%E9%A6%96%E9%A1%B5%E6%91%98%E8%A6%81)
- [自定义文章在首页的摘要](https://github.com/fi3ework/hexo-theme-archer/wiki/%E8%87%AA%E5%AE%9A%E4%B9%89%E6%96%87%E7%AB%A0%E5%9C%A8%E9%A6%96%E9%A1%B5%E7%9A%84%E6%91%98%E8%A6%81)
- [自定义主题颜色](https://github.com/fi3ework/hexo-theme-archer/wiki/%E6%9B%B4%E6%94%B9%E4%B8%BB%E9%A2%98%E9%A2%9C%E8%89%B2)
- [切换代码配色方案](https://github.com/fi3ework/hexo-theme-archer/wiki/%E5%88%87%E6%8D%A2%E4%BB%A3%E7%A0%81%E9%85%8D%E8%89%B2%E6%96%B9%E6%A1%88)
- [置顶文章](https://www.jianshu.com/p/42a4efcdf8d7)
Expand All @@ -105,133 +107,9 @@ jsonContent:

## 主题配置

```yaml
# ========== 资料栏 ========== #
# 头像路径
avatar:
# 博主名字,不填写该字段则默认采用 Hexo 配置文件中的 author 字段
author:
# 博客签名
signature:
# 社交账号(可以自定义顺序)
social:
email:
github:
# wechat 和 qq 需要填写二维码图片的路径
wechat:
qq:
telegram:
weibo:
zhihu:
douban:
facebook:
twitter:
instagram:
stack-overflow:
segmentFault:
juejin:
v2ex:
linkedin:
blog:
others:
rss: /atom.xml
# 友链
friends:
friendA:
friendB:
friendC:
# about 页面
about:
# 是否启用 about 页
enable: true
# about 页头图
image:
# ========== 站点 ========== #
# 网站的 title,每篇文章后面也会加上此字段利于 SEO
SEO_title:
# 网站的关键字,有利于 SEO,每篇文章也可以在 Front-matter 添加特定的关键字
SEO_keywords:
# 显示在网站头图上的主标题
main_title:
# 显示在网站头图上的副标题
subtitle:
# 主页头图
header_image:
# 文章页默认头图
post_header_image:
# 404 页头图
_404_image:
# ========== 搜索 ========== #
algolia_search:
enable: false
hits:
per_page: 10 # 每页的结果数
labels:
input_placeholder: Search for Posts # 搜索栏 placeholder
hits_empty: "We did not find any results for the search: ${query}" # 搜索结果提示
hits_stats: "${hits} results found in ${time} ms" # 搜索无结果的提示
# ========== 评论插件 ========== #
# 目前支持直接添加 Livere,Disqus,Gitment,Gitalk,友言及 Valine,填写插件对应的字段即可启用。(推荐使用 Livere)
# 如果想添加其他评论插件,在 custom.ejs 中添加即可。
comment:
# Livere 官网:https://livere.com/
livere_uid:
# Disqus 官网:https://disqus.com/
disqus_shortname:
# Gitment 官网:https://github.com/imsun/gitment
gitment_owner:
gitment_repo:
gitment_client_id:
gitment_client_secret:
# 友言 官网: http://www.uyan.cc/
youyan_uid:
# Valine 官网: https://valine.js.org/
valine_appId:
valine_appKey:
valine_placeHolder:
# gitalk 官网: https://github.com/gitalk
gitalk_client_id:
gitalk_client_secret:
gitalk_admin:
gitalk_owner:
gitalk_repo:
# utteranc 官网: https://utteranc.es/
utteranc_repo:
utteranc_label:
utteranc_theme:
utteranc_issue_term:
# ========== 统计 ========== #
# 是否开启不蒜子阅读量统计
busuanzi: true
# 统计方式,填写 pv 或 uv
busuanzi_pv_or_uv: 'pv'
# 自定义统计标语,'${count}' 会自动替换成统计值
busuanzi_slug: 'PV: ${count} :)'
# 百度统计(填写 siteID)
baidu_analytics:
# Google统计(填写 siteID)
google_analytics:
# CNZZ统计
CNZZ_analytics:
# ========== 其他 ========== #
# 网站的标签页缩略图
favicon:
# 首页的文章摘要字数(默认300,填0则不显示摘要)
truncate_length:
# 开启文章右侧的大纲
toc: true
# 字数统计 & 阅读时间
reading_info: true
# 头图高度 (默认是屏幕高度的 50%, 可以直接输入其他数字)
index_intro_height: 50
post_intro_height: 50
about_intro_height: 50
```
复制 [_config.yml](./_config.yml) 到 hexo 根目录,并改名为 **_config.archer.yml**,再对值做修改。(Hexo 2.8.2 之后的特性)

**注意** 不要把自己 api token 之类的敏感信息推送到公共仓库

## 更新主题

Expand Down
3 changes: 3 additions & 0 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,6 @@ copyright:
enable: true
# https://creativecommons.org/
license: '本文采用<a rel="license" href="http://creativecommons.org/licenses/by-nc/4.0/">知识共享署名-非商业性使用 4.0 国际许可协议</a>进行许可'
# 超过以下天数,在对应的文章页面提示“注意文章时效性”,0 则不提示
outdated_threshold: 0

40 changes: 21 additions & 19 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,67 @@ const gulp = require('gulp'),
/* ========== develop ========== */

// webpack
gulp.task('webpack', function (cb) {
function execWebpack(cb) {
webpack(require('./webpack.config.js'), function (err) {
if (err) return cb(err)
cb()
})
})
}

// sass
gulp.task('sass', function () {
function execSass() {
return gulp.src(['./src/scss/style.scss', './src/scss/mobile.scss'])
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(gulp.dest('./source/css/'))
})
}

// browser-sync
// watch js
gulp.task('reload-js', ['webpack'], function (done) {
const reloadJs = gulp.series(execWebpack, function (done) {
browserSync.reload()
done()
})
// watch sass
gulp.task('reload-css', ['sass'], function (done) {
const reloadCss = gulp.series(execSass, function (done) {
browserSync.reload()
done()
})
// watch layout
gulp.task('reload-layout', function (done) {
function reloadLayout(done) {
browserSync.reload()
done()
})
}
// watch _config
gulp.task('reload-config', function (done) {
function reloadConfig(done) {
browserSync.reload()
done()
})
}

gulp.task('dev', ['webpack', 'sass'], function () {
exports.dev = gulp.series(execWebpack, execSass, function (cb) {
browserSync.init({
proxy: 'localhost:4000'
})
gulp.watch(['./src/js/**/*.js'], ['reload-js'])
gulp.watch(['./src/scss/**/*.scss'], ['reload-css'])
gulp.watch(['./layout/**/*.ejs'], ['reload-layout'])
gulp.watch(['./_config.yml'], ['reload-config'])
gulp.watch(['./src/js/**/*.js'], reloadJs)
gulp.watch(['./src/scss/**/*.scss'], reloadCss)
gulp.watch(['./layout/**/*.ejs'], reloadLayout)
gulp.watch(['./_config.yml'], reloadConfig)
cb()
})


/* ========== bulid ========== */

// webpack-prod
gulp.task('webpack-prod', function (cb) {
function webpackProd(cb) {
webpack(require('./webpack.prod.js'), function (err) {
if (err) return cb(err)
cb()
})
})
}

gulp.task('build', ['sass', 'webpack-prod'], function () {
exports.build = gulp.series(execSass, webpackProd, function (cb) {
cb()
console.log(process.argv)
})
})
3 changes: 2 additions & 1 deletion layout/_partial/algolia.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
<i class="iconfont-archer">&#xe609;</i>
</span>
</div>
</div>
</div>

11 changes: 6 additions & 5 deletions layout/_partial/base-head.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,28 @@
<% } %>
<title><%= title %></title>
<%- partial('critical-css/critical-style') %>
<link rel="preload" href= "<%- url_for("css/style.css?v=20180824") %>" as="style" onload="this.onload=null;this.rel='stylesheet'" />
<link rel="stylesheet" href= "<%- url_for("css/mobile.css?v=20180824") %>" media="(max-width: 980px)">
<link rel="preload" href= "<%- url_for("css/style.css?v=20210204") %>" as="style" onload="this.onload=null;this.rel='stylesheet'" />
<link rel="stylesheet" href= "<%- url_for("css/mobile.css?v=20210204") %>" media="(max-width: 980px)">
<% if(!is_home()) { %>
<link rel="preload" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'" />
<% } %>
<%- partial('base-preload-polyfill') %>
<link rel="icon" href= "<%- url_for(theme.favicon) %>" />
<link rel="preload" href="https://cdn.jsdelivr.net/npm/webfontloader@1.6.28/webfontloader.min.js" as="script" />
<link rel="preload" href="https://cdn.jsdelivr.net/npm/jquery@3.3.1/dist/jquery.min.js" as="script" />
<link rel="preload" href="<%- url_for('scripts/main.js') %>" as="script" />
<link rel="preload" href="<%- url_for('scripts/main.js') %>?v=20210204" as="script" />
<link rel="preload" as="font" href="<%- url_for('font/Oswald-Regular.ttf') %>" crossorigin>
<link rel="preload" as="font" href="https://at.alicdn.com/t/font_327081_1dta1rlogw17zaor.woff" crossorigin>
<% if (theme.algolia_sarch != undefined && theme.algolia_search.enable) { %>
<script src="https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.2/js/all.min.js" data-auto-replace-svg="nest" ></script>
<% if (theme.algolia_search != undefined && theme.algolia_search.enable) { %>
<!-- algolia -->
<script>
<% var algoliaHits = JSON.stringify(theme.algolia_search.hits) %>
var hits = JSON.parse('<%- JSON.stringify(theme.algolia_search.hits) %>')
var labels = JSON.parse('<%- JSON.stringify(theme.algolia_search.labels) %>')
var algolia = {
applicationID: '<%- config.algolia.applicationID %>',
appId: '<%- config.algolia.appId %>',
apiKey: '<%- config.algolia.apiKey %>',
indexName: '<%- config.algolia.indexName %>',
hits: hits,
Expand Down
12 changes: 10 additions & 2 deletions layout/layout.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<!-- algolia -->
<% if (theme.algolia_search.enable) { %>
<%- partial('_partial/algolia') %>
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@2.8.0/dist/instantsearch.min.js" defer></script>
<script src="https://cdn.jsdelivr.net/npm/instantsearch.js@4.8.3/dist/instantsearch.production.min.js" integrity="sha256-LAGhRRdtVoD6RLo2qDQsU2mp+XVSciKRC8XPOBWmofM=" crossorigin="anonymous"></script>
<script src="<%- url_for('/scripts/search.js') %>" defer></script>
<% } %>
<!-- busuanzi -->
Expand All @@ -61,7 +61,15 @@
<!-- CNZZ -->
<% if (theme.CNZZ_analytics) { %>
<div style="display: none">
<script src="https://s13.cnzz.com/z_stat.php?id=<%- theme.CNZZ_analytics %>&web_id=<%- theme.CNZZ_analytics %>" language="JavaScript"></script>
<script>
var cnzz_s_tag = document.createElement('script');
cnzz_s_tag.type = 'text/javascript';
cnzz_s_tag.async = true;
cnzz_s_tag.charset = 'utf-8';
cnzz_s_tag.src = 'https://w.cnzz.com/c.php?id=<%- theme.CNZZ_analytics %>&async=1';
var root_s = document.getElementsByTagName('script')[0];
root_s.parentNode.insertBefore(cnzz_s_tag, root_s);
</script>
<% } %>
</div>
<!-- async load share.js -->
Expand Down
25 changes: 24 additions & 1 deletion layout/post.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,27 @@
<%- partial('_partial/comment/custom') %>
<%- partial('_partial/comment/valine') %>
<!-- 评论 -->
</main>

<!-- idea from: https://hexo.fluid-dev.com/posts/hexo-injector/#%E6%96%87%E7%AB%A0%E6%97%B6%E6%95%88%E6%80%A7%E6%8F%90%E7%A4%BA -->
<% if (theme.outdated_threshold != 0){ %>
<script>
(function(){
var time = document.getElementsByClassName('post-intro-time')[0]
if (time === undefined) { return; }
var post = document.getElementsByTagName("article")[0]
if (post === undefined) { return; }
var pubTime = new Date(time.innerText)
var now = Date.now()
var interval = parseInt(now - pubTime)
var days = parseInt(interval / 86400000)
var outdated_threshold = parseInt(<%- theme.outdated_threshold %>)
if (interval > outdated_threshold*24*3600*1000){
post.innerHTML = '<div class="note note-warning" style="font-size:0.9rem"><p>' +
'<div class="title">文章时效性提示</div><p>这是一篇发布于 ' + days + ' 天前的文章,部分信息可能已发生改变,请注意甄别。' +
'</p></p></div>' + post.innerHTML;
}
})();
</script>
<% } %>
</main>
Loading

0 comments on commit c79ede0

Please sign in to comment.