icarus配置

Version of the Icarus theme that is currently used

version: 2.3.0

你的网站图标,可以搜索在线图标制作,并将其放在images文件夹中

favicon: /images/favicons.ico

Path or URL to RSS atom.xml

rss: /atom.xml

显示在导航栏左侧的网站logo,同样可以自己制作

logo: /images/gen.svg

Open Graph metadata

https://hexo.io/docs/helpers.html#open-graph

open_graph:
# Facebook App ID
fb_app_id:
# Facebook Admin ID
fb_admins:
# Twitter ID
twitter_id:
# Twitter site
twitter_site:
# Google+ profile link
google_plus:

导航栏

navbar:
#菜单(显示名称:对应文件夹)
menu:
主页: /
归档: /archives
分类: /categories
标签: /tags
关于: /about
# 导航栏右侧图标链接
links:
My GitHub:
icon: fab fa-github
url: ‘你的gityhub地址’

Footer section link settings

footer:
# 页脚图标链接
links:
Creative Commons:
icon: fab fa-creative-commons
url: ‘https://creativecommons.org/'
Attribution 4.0 International:
icon: fab fa-creative-commons-by
url: ‘https://creativecommons.org/licenses/by/4.0/'
Download on GitHub:
icon: fab fa-github
url: ‘http://github.com/ppoffice/hexo-theme-icarus'

文章显示设置

article:
# Code highlight theme
# https://github.com/highlightjs/highlight.js/tree/master/src/styles
#代码主题atom-one-light亮色,atom-one-dark暗色
highlight: atom-one-dark
# 是否显示文章主图
thumbnail: true
# 是否显示估算阅读时间
readtime: true

搜索插件设置

http://ppoffice.github.io/hexo-theme-icarus/categories/Configuration/Search-Plugins

search:
# Name of the search plugin
type: insight

评论插件设置

http://ppoffice.github.io/hexo-theme-icarus/categories/Configuration/Comment-Plugins

comment:
#可选valine,disqus(科学上网)等
# Name of the comment plugin
#type: valine
#app_id: 不为空
#app_key: 不为空
#notify: true
#verify: true
#placeholder:
type: disqus
shortname: 不能为空

打赏功能

http://ppoffice.github.io/hexo-theme-icarus/categories/Donation/

donate:
-
# 阿里巴巴支付宝
type: alipay
# 二维码图片
qrcode: ‘/images/honbao.PNG’
-
# 微信
type: wechat
# 二维码图片
qrcode: ‘/images/yjtp.png’
-

分享插件设置

http://ppoffice.github.io/hexo-theme-icarus/categories/Configuration/Share-Plugins

share:
# 插件类型,有多种,可选,自行百度
type: sharejs

Sidebar settings.

Please be noted that a sidebar is only visible when it has at least one widget

sidebar:
# 左侧边栏设置
left:
# 是否不随页面滚动
# http://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/make-a-sidebar-sticky-when-page-scrolls/
sticky: false
# 右侧边栏设置
right:
# 是否不随页面滚动
# http://ppoffice.github.io/hexo-theme-icarus/Configuration/Theme/make-a-sidebar-sticky-when-page-scrolls/
sticky: false

边栏小部件设置

http://ppoffice.github.io/hexo-theme-icarus/categories/Widgets/

widgets:
-
# 个人信息
type: profile
# 部件位置(左)
position: left
# 作者名(字符串)
author: 飞鱼
# 作者身份描述(字符串)
author_title: Student
# 作者当前居住地
location: China,Fujian
# 头像(可用本地图片或网络图片链接)
avatar: ‘/images/ava.png’
# Email address for the Gravatar to be shown in the profile widget
gravatar:
# 关注我的链接,可设为你的GitHub主页
follow_link: ‘https://github.com/yourname'
# 个人介绍部件底部图标社交链接
social_links:
Github:
icon: fab fa-github
url: ‘https://github.com/yourname'
Facebook:
icon: fab fa-facebook
url: ‘https://facebook.com'
Twitter:
icon: fab fa-twitter
url: ‘https://twitter.com/yourname'
RSS:
icon: fas fa-rss
url: /
-
# Widget name
type: toc
# Where should the widget be placed, left or right
position: left
-
# 分类
type: category
# 位置指定
position: left
-
# 标签云
type: tagcloud
# 位置
position: right
-
# 近期文章
type: recent_posts
# 位置
position: left
-
# 归档
type: archive
# Where should the widget be placed, left or right
position: right
-
# 标签
type: tag
# Where should the widget be placed, left or right
position: right
-
# 外部链接
type: links
# Where should the widget be placed, left or right
position: left
# Links to be shown in the links widget
links:
Google: ‘https://google.com'
Baidu: ‘https://baidu.com'

icarus配置2

  1. 修改navbar导航栏左边的logo配置方式
    因为不会设计Logo, 就改成”icon+文字”的方式, 并加入logo.img配置项

themes/hexo-theme-icarus/layout/common/navbar.ejs
2. 修改navbar导航栏右边的搜索功能
原版2.3.0只有一个小的搜索icon, 加入搜索输入框并嵌入搜索icon

themes/hexo-theme-icarus/layout/common/navbar.ejs
themes/hexo-theme-icarus/source/css/style.styl
3. 修改个人信息页中的几个links
原版是通过socialLinks动态配置的, 不支持微信, 码云, 微博这几个常用, 这里为了方便我使用+标签写死

themes/hexo-theme-icarus/layout/widget/profile.ejs
4. 友情链接标题前加入icon, 为了好看
themes/hexo-theme-icarus/layout/widget/links.ejs
5. 修改文章页(index页和post页)的文章时间
加入判断, 如果是列表页显示例如几月前, 文章页显示具体日期, 例如2018-12-22

themes/hexo-theme-icarus/layout/common/article.ejs
6. 修改文章详情页面不显示文章图片thumbnail
在阅读文章时感觉有点花, 默认是index页和post页都会显示

themes/hexo-theme-icarus/layout/common/article.ejs
7. 修改首页文章列表摘要信息不显示样式
去掉Markdown生成的html标签, 类似简书上的文章排版, 整洁一点

themes/hexo-theme-icarus/layout/common/article.ejs
8. 修改文章页面布局
原版的主页和文章页都使用三栏布局, 在文章页阅读会显得内容很窄, 尤其是代码部分, 需要左右滚动, 故修改文章页为两栏布局

themes/hexo-theme-icarus/includes/helpers/layout.js
themes/hexo-theme-icarus/layout/common/widget.ejs
themes/hexo-theme-icarus/layout/layout.ejs
themes/hexo-theme-icarus/source/css/style.styl
9. 目录的开启方式改为默认就开启文章目录
这样可以不用每个md文件都去写toc: true

themes/hexo-theme-icarus/includes/helpers/config.js
10. 修改开启目录后的显示问题
默认目录在滚动文章时如果太长会显示不全, 所以增加目录粘性布局

themes/hexo-theme-icarus/layout/widget/toc.ejs
11. 文章页增加版权声明
themes/hexo-theme-icarus/layout/common/article.ejs
themes/hexo-theme-icarus/source/css/style.styl
12. 修改底部footer的显示信息
themes/hexo-theme-icarus/layout/common/footer.ejs
配合gulp压缩
主要是为了在hexo generate到public目录后, 压缩html, css, js等资源

经过压缩, 我的public目录大小从8MB降到5MB, 还是可以的

第一次用压缩工具, 记录下gulp的安装和使用, 及配合hexo icarus主题进行压缩时的几个问题

安装
npm install gulp –save
npm install gulp -g
还需要以下模块

gulp-htmlclean: 清理html
gulp-htmlmin: 压缩html
gulp-minify-css: 压缩css
gulp-uglify: 混淆js
gulp-imagemin: 压缩图片
执行安装命令

npm install gulp-htmlclean gulp-htmlmin gulp-minify-css gulp-uglify gulp-imagemin –save
最好在安装一个可以打印错误日志的工具, 之后会用到:

npm install –save-dev gulp-util
建立任务
在hexo根目录建立文件gulpfile.js, 内容如下:

var gulp = require(‘gulp’);
var minifycss = require(‘gulp-minify-css’);
var uglify = require(‘gulp-uglify’);
var htmlmin = require(‘gulp-htmlmin’);
var htmlclean = require(‘gulp-htmlclean’);
var imagemin = require(‘gulp-imagemin’);
var gutil = require(‘gulp-util’);

// 压缩html
gulp.task(‘minify-html’, function() {
return gulp.src(‘./public//*.html’)
.pipe(htmlclean())
.pipe(htmlmin({
removeComments: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
}))
.pipe(gulp.dest(‘./public’))
});
// 压缩html
gulp.task(‘minify-xml’, function() {
return gulp.src(‘./public/
/.xml’)
.pipe(htmlclean())
.pipe(htmlmin({
removeComments: true,
minifyJS: true,
minifyCSS: true,
minifyURLs: true,
}))
.pipe(gulp.dest(‘./public’))
});
// 压缩css
gulp.task(‘minify-css’, function() {
return gulp.src(‘./public/**/
.css’)
.pipe(minifycss({
compatibility: ‘ie8’
}))
.pipe(gulp.dest(‘./public’));
});
// 压缩js
gulp.task(‘minify-js’, function() {
return gulp.src(‘./public/js/*/.js’)
.pipe(uglify())
.pipe(gulp.dest(‘./public’));
});

// 压缩js
gulp.task(‘minify-js’, function() {
return gulp.src(‘./public/js/*/.js’)
.pipe(uglify())
.on(‘error’, function (err) { gutil.log(gutil.colors.red(‘[Error]’), err.toString()); })
.pipe(gulp.dest(‘./public’));
});

// 压缩图片
gulp.task(‘minify-images’, function() {
return gulp.src(‘./public/img/*/.*’)
.pipe(imagemin(
[imagemin.gifsicle({‘optimizationLevel’: 3}),
imagemin.jpegtran({‘progressive’: true}),
imagemin.optipng({‘optimizationLevel’: 7}),
imagemin.svgo()],
{‘verbose’: true}))
.pipe(gulp.dest(‘./public/img’))
});
// 默认任务
gulp.task(‘default’, [
‘minify-html’,’minify-xml’,’minify-css’,’minify-js’,’minify-images’
]);
问题一: gulp版本
在Hexo根目录执行gulp, 错误如下:

AssertionError: Task function must be specified。
版本问题导致的, 可以查看下gulp版本: gulp -v

修改package.json中的gulp版本为3.x, 例如:

“dependencies”: {
“gulp”: “^3.9.1”,
// …
}
然后重新安装gulp: npm install gulp

问题二: icarus主题中的js语法问题
接下来gulp可能会发生如下错误:

GulpUglifyError: unable to minify JavaScript
原因是javascirpt语法问题,在es5环境里使用了es6、es7语法

因为上面安装部分和gulpfile.js中已经添加了错误打印, 可以看到具体的错误信息

我修改了如下js文件:

themes/hexo-theme-icarus/source/js/back-to-top.js
themes/hexo-theme-icarus/source/js/clipboard.js
themes/hexo-theme-icarus/source/js/main.js

作者:i蝸居年華_谢谢谢
链接:
https://www.jianshu.com/p/815adbb220a3
来源:简书

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×