Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
a38c874bb4 | ||
|
63497f1ad2 | ||
|
42b387c94a | ||
|
11a4aaacf2 | ||
|
ca99e5de86 | ||
|
758b378e82 | ||
|
a8b0534861 | ||
|
246cae5164 | ||
|
4e57d75cb9 | ||
|
faef444acd | ||
|
38131011fc |
@@ -100,6 +100,12 @@ nav_text:
|
|||||||
# Catalog in article
|
# Catalog in article
|
||||||
toc: true
|
toc: true
|
||||||
|
|
||||||
|
# https://github.com/willin/hexo-wordcount
|
||||||
|
word_count:
|
||||||
|
enable: true
|
||||||
|
# only display in article page(not in index page)
|
||||||
|
only_article_visit: true
|
||||||
|
|
||||||
# Reward Setting
|
# Reward Setting
|
||||||
# type:0-close reward; 1-only open in article which you have configured reward:true; 2-open in all articles
|
# type:0-close reward; 1-only open in article which you have configured reward:true; 2-open in all articles
|
||||||
reward_type: 2
|
reward_type: 2
|
||||||
|
@@ -36,6 +36,14 @@ nav_text:
|
|||||||
# 文章页是否显示目录
|
# 文章页是否显示目录
|
||||||
toc: true
|
toc: true
|
||||||
|
|
||||||
|
# https://github.com/willin/hexo-wordcount
|
||||||
|
# 是否开启字数统计(关闭请设置enable为false)
|
||||||
|
# 也可以单独在md文件里Front-matter设置`no_word_count: true`属性,来自定义关闭字数统计
|
||||||
|
word_count:
|
||||||
|
enable: true
|
||||||
|
# 只在文章详情显示(不在首页显示)
|
||||||
|
only_article_visit: true
|
||||||
|
|
||||||
# 打赏
|
# 打赏
|
||||||
# 打赏type设定:0-关闭打赏; 1-文章对应的md文件里有reward:true属性,才有打赏; 2-所有文章均有打赏
|
# 打赏type设定:0-关闭打赏; 1-文章对应的md文件里有reward:true属性,才有打赏; 2-所有文章均有打赏
|
||||||
reward_type: 2
|
reward_type: 2
|
||||||
|
@@ -19,6 +19,10 @@
|
|||||||
positionFixedSelector: '.tocbot',
|
positionFixedSelector: '.tocbot',
|
||||||
positionFixedClass: 'is-position-fixed',
|
positionFixedClass: 'is-position-fixed',
|
||||||
fixedSidebarOffset: 'auto',
|
fixedSidebarOffset: 'auto',
|
||||||
|
onClick: (e) => {
|
||||||
|
document.getElementById(e.target.innerText).scrollIntoView()
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
@@ -9,8 +9,9 @@
|
|||||||
else title = __('archive_a');
|
else title = __('archive_a');
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
|
<% if (pagination !== 2){ %>
|
||||||
<h1 class="page-type-title"><%- title %></h1>
|
<h1 class="page-type-title"><%- title %></h1>
|
||||||
|
<% } %>
|
||||||
<% if (pagination == 2){ %>
|
<% if (pagination == 2){ %>
|
||||||
<% page.posts.each(function(post){ %>
|
<% page.posts.each(function(post){ %>
|
||||||
<%- partial('article', {post: post, index: true}) %>
|
<%- partial('article', {post: post, index: true}) %>
|
||||||
|
@@ -12,6 +12,9 @@
|
|||||||
<div class="article-meta">
|
<div class="article-meta">
|
||||||
<%- partial('post/date', {class_name: 'article-date', date_format: null}) %>
|
<%- partial('post/date', {class_name: 'article-date', date_format: null}) %>
|
||||||
<%- partial('post/category') %>
|
<%- partial('post/category') %>
|
||||||
|
<% if(theme.word_count && theme.word_count.enable && !post.no_word_count){%>
|
||||||
|
<%- partial('post/word') %>
|
||||||
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
@@ -31,11 +34,11 @@
|
|||||||
<%- post.content %>
|
<%- post.content %>
|
||||||
<% } %>
|
<% } %>
|
||||||
<!-- 打赏 -->
|
<!-- 打赏 -->
|
||||||
<% if ((theme.reward_type === 2 || (theme.reward_type === 1 && post.reward)) && !index){ %>
|
<% if ((theme.reward_type === 2 || (theme.reward_type === 1 && post.reward)) && !index && !post.no_reward){ %>
|
||||||
<div id="reward-btn">
|
<div id="reward-btn">
|
||||||
打赏
|
打赏
|
||||||
</div>
|
</div>
|
||||||
<% } %>
|
<% } %>
|
||||||
</div>
|
</div>
|
||||||
<footer class="article-footer">
|
<footer class="article-footer">
|
||||||
<a data-url="<%- post.permalink %>" data-id="<%= post._id %>"
|
<a data-url="<%- post.permalink %>" data-id="<%= post._id %>"
|
||||||
@@ -49,7 +52,7 @@
|
|||||||
<%- partial('post/nav') %>
|
<%- partial('post/nav') %>
|
||||||
<% } %>
|
<% } %>
|
||||||
|
|
||||||
<% if (theme.valine && theme.valine.enable){ %>
|
<% if (theme.valine && theme.valine.enable && !post.no_valine){ %>
|
||||||
<%- partial('post/valine', {
|
<%- partial('post/valine', {
|
||||||
key: post.slug,
|
key: post.slug,
|
||||||
title: post.title,
|
title: post.title,
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="cover-learn-more">
|
<div class="cover-learn-more">
|
||||||
<a href="#main" class="anchor"><i class="ri-arrow-down-line"></i></a>
|
<a href="javascript:void(0)" class="anchor"><i class="ri-arrow-down-line"></i></a>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
<% } %>
|
<% } %>
|
@@ -8,7 +8,7 @@
|
|||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<% if (theme.pageFooter){ %>
|
<% if (theme.pageFooter){ %>
|
||||||
Power by
|
Powered by
|
||||||
<% var hexoLink = '<a href="https://hexo.io" target="_blank">Hexo</a>'; %>
|
<% var hexoLink = '<a href="https://hexo.io" target="_blank">Hexo</a>'; %>
|
||||||
<% var themeLink = '<a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>'; %>
|
<% var themeLink = '<a href="https://github.com/Shen-Yu/hexo-theme-ayer" target="_blank">Ayer</a>'; %>
|
||||||
<%- hexoLink %> Theme <%- themeLink %>
|
<%- hexoLink %> Theme <%- themeLink %>
|
||||||
|
20
layout/_partial/post/word.ejs
Normal file
20
layout/_partial/post/word.ejs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
<% if (!theme.word_count.only_article_visit || (!index && theme.word_count.only_article_visit)){ %>
|
||||||
|
<div class="word_count">
|
||||||
|
<span class="post-time">
|
||||||
|
<span class="post-meta-item-icon">
|
||||||
|
<i class="ri-quill-pen-line"></i>
|
||||||
|
<span class="post-meta-item-text"> 字数统计:</span>
|
||||||
|
<span class="post-count"><%= wordcount(post.content) %>字</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<span class="post-time">
|
||||||
|
|
|
||||||
|
<span class="post-meta-item-icon">
|
||||||
|
<i class="ri-book-open-line"></i>
|
||||||
|
<span class="post-meta-item-text"> 阅读时长≈</span>
|
||||||
|
<span class="post-count"><%= min2read(post.content) %>分钟</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<% } %>
|
8
scripts/default_config.js
Normal file
8
scripts/default_config.js
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
|
||||||
|
// 生成meta `generator`
|
||||||
|
meta_generator: true
|
||||||
|
|
||||||
|
};
|
13
scripts/filters/index.js
Normal file
13
scripts/filters/index.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const metaGeneratorPath = './meta_generator';
|
||||||
|
|
||||||
|
module.exports = hexo => {
|
||||||
|
/* const {
|
||||||
|
filter
|
||||||
|
} = hexo.extend; */
|
||||||
|
// filter.register('after_render:html', require('./meta_generator'));
|
||||||
|
};
|
||||||
|
|
||||||
|
// 保持过滤器最先执行
|
||||||
|
hexo.extend.filter.register('after_render:html', require(metaGeneratorPath), 1);
|
17
scripts/filters/meta_generator.js
Normal file
17
scripts/filters/meta_generator.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const defaultConfig = require('../default_config');
|
||||||
|
|
||||||
|
function hexoMetaGeneratorInject(data) {
|
||||||
|
const config = defaultConfig;
|
||||||
|
if (!config.meta_generator || !data ||
|
||||||
|
data.match(/<meta\s+name=['|"]?generator['|"]?/i)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const hexoGeneratorTag = `\n <meta name="generator" content="hexo-theme-yilia-plus">`;
|
||||||
|
|
||||||
|
return data.replace('</title>', '</title>' + hexoGeneratorTag);
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = hexoMetaGeneratorInject;
|
9
scripts/helpers/ayer-plus-vendors.js
Normal file
9
scripts/helpers/ayer-plus-vendors.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
/* global hexo */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
/** 自定义链接生成 */
|
||||||
|
hexo.extend.helper.register('ayer_plus_vendors', function (url) {
|
||||||
|
if (url.startsWith('//')) return url;
|
||||||
|
return this.url_for(`${url}`);
|
||||||
|
});
|
39
scripts/helpers/wordcount.js
Normal file
39
scripts/helpers/wordcount.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
var util = require('hexo-util');
|
||||||
|
var stripHTML = util.stripHTML;
|
||||||
|
|
||||||
|
var counter = function (content) {
|
||||||
|
content = stripHTML(content);
|
||||||
|
const cn = (content.match(/[\u4E00-\u9FA5]/g) || []).length;
|
||||||
|
const en = (content.replace(/[\u4E00-\u9FA5]/g, '').match(/[a-zA-Z0-9_\u0392-\u03c9\u0400-\u04FF]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af\u0400-\u04FF]+|[\u00E4\u00C4\u00E5\u00C5\u00F6\u00D6]+|\w+/g) || []).length;
|
||||||
|
return [cn, en];
|
||||||
|
};
|
||||||
|
|
||||||
|
hexo.extend.helper.register('min2read', function (content, {
|
||||||
|
cn = 300,
|
||||||
|
en = 160
|
||||||
|
} = {}) {
|
||||||
|
var len = counter(content);
|
||||||
|
var readingTime = len[0] / cn + len[1] / en;
|
||||||
|
return readingTime < 1 ? '1' : parseInt(readingTime, 10);
|
||||||
|
});
|
||||||
|
|
||||||
|
hexo.extend.helper.register('wordcount', function (content) {
|
||||||
|
var len = counter(content);
|
||||||
|
var count = len[0] + len[1];
|
||||||
|
if (count < 1000) {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
return Math.round(count / 100) / 10 + 'k';
|
||||||
|
});
|
||||||
|
|
||||||
|
hexo.extend.helper.register('totalcount', function (site) {
|
||||||
|
var count = 0;
|
||||||
|
site.posts.forEach(function (post) {
|
||||||
|
var len = counter(post.content);
|
||||||
|
count += len[0] + len[1];
|
||||||
|
});
|
||||||
|
if (count < 1000) {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
return Math.round(count / 100) / 10 + 'k';
|
||||||
|
});
|
25
scripts/lib/core.js
Normal file
25
scripts/lib/core.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/* global hexo */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Hexo事件:https://hexo.io/zh-cn/api/events
|
||||||
|
|
||||||
|
/** 在静态文件生成前发布 */
|
||||||
|
hexo.on('generateBefore', () => {
|
||||||
|
// Merge config.
|
||||||
|
//require('./../filters/index')(hexo);
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 在文章文件建立后发布。该事件返回文章参数。 */
|
||||||
|
hexo.on('new', function (post) {
|
||||||
|
//console.log(post)
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 在文章开始渲染前执行 */
|
||||||
|
hexo.extend.filter.register('before_post_render', function (data) {
|
||||||
|
//var config = hexo.config;
|
||||||
|
//console.log(3);
|
||||||
|
//console.log(config);
|
||||||
|
//console.log(hexo.theme.config);
|
||||||
|
|
||||||
|
});
|
@@ -34,8 +34,7 @@ $base-style
|
|||||||
acronym, abbr
|
acronym, abbr
|
||||||
border-bottom border-width border-color dotted
|
border-bottom border-width border-color dotted
|
||||||
ul, ol, dl
|
ul, ol, dl
|
||||||
margin 1.5rem 0
|
margin 1.5rem 0 1.5rem 2rem
|
||||||
line-height line-height
|
|
||||||
|
|
||||||
p, table, blockquote
|
p, table, blockquote
|
||||||
margin 1.5rem 0
|
margin 1.5rem 0
|
||||||
|
@@ -53,7 +53,7 @@
|
|||||||
|
|
||||||
.article-entry
|
.article-entry
|
||||||
font-size 110%
|
font-size 110%
|
||||||
margin-top 1rem
|
margin-top .5rem
|
||||||
clearfix()
|
clearfix()
|
||||||
@extend $base-style
|
@extend $base-style
|
||||||
color body-color
|
color body-color
|
||||||
|
@@ -71,6 +71,12 @@
|
|||||||
z-index 9998
|
z-index 9998
|
||||||
display none
|
display none
|
||||||
|
|
||||||
|
.word_count
|
||||||
|
margin-top 5px
|
||||||
|
color darken(gray,30%)
|
||||||
|
padding-bottom 1rem
|
||||||
|
border-bottom 1px solid darken(froth-light,2%)
|
||||||
|
|
||||||
// Media Query
|
// Media Query
|
||||||
@media (max-width: 768px)
|
@media (max-width: 768px)
|
||||||
.cover-inner
|
.cover-inner
|
||||||
|
@@ -137,11 +137,11 @@
|
|||||||
margins: 5
|
margins: 5
|
||||||
});
|
});
|
||||||
|
|
||||||
//
|
// scroll down
|
||||||
$(document).ready(function ($) {
|
$(document).ready(function ($) {
|
||||||
$('.anchor').click(function (event) {
|
$('.anchor').click(function (e) {
|
||||||
event.preventDefault();
|
e.preventDefault();
|
||||||
$('main').animate({ scrollTop: $(this.hash).offset().top }, 'smooth');
|
$('main').animate({ scrollTop: $('.cover').height() }, 'smooth');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user