一、添加emoji显示功能
1 2 3
| npm un hexo-renderer-marked npm i hexo-renderer-markdown-it npm install markdown-it-emoji
|
一般需要卸载原来的插件,但是我发现我的文件夹里并没有hexo-renderer-marked也就没有删了。
在_config.yml中添加以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
| markdown: render: html: true xhtmlOut: false breaks: true linkify: false typographer: true quotes: '“”‘’' plugins: - markdown-it-abbr - markdown-it-footnote - markdown-it-ins - markdown-it-sub - markdown-it-sup - markdown-it-emoji
|
由于那个链接的东西实在是太丑了,我就注释掉了😣
使用:persevere:这样的语法就可以显示上面那个表情啦。具体可以参考https://www.cnblogs.com/zhaoruiqing/articles/12870209.html
二、添加live2D
在_config.yml中添加以下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| live2d: enable: true scriptFrom: local pluginRootPath: live2dw/ pluginJsPath: lib/ pluginModelPath: assets/ tagMode: false debug: false model: use: live2d-widget-model-tororo display: position: right width: 150 height: 300 hOffset: 5 vOffset: -60 mobile: show: false react: opacity: 1.0
|
再使用cmd命令下载模型
1
| npm install live2d-widget-model-tororo
|
其他模型可以参考该仓库:https://github.com/xiazeyu/live2d-widget-models
在根目录里新建一个文件夹live2d_models,然后把模型放进去即可
三、添加音乐播放器(具有收入侧栏的功能)
事实上,我选用的主题fluid自带有aplayer音乐播放器
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| aplayer: enable: true autoplay: false loop: 'all' order: 'random' theme: '#b7daff' songs: - { name: 'Flaming', artist: '郑晟河', url: '/Wuhlan3/mp3/song1.mp3', cover: '/Wuhlan3/img/song1.jpg' } - { name: '流れ行く雲', artist: '岸部真明', url: '/Wuhlan3/mp3/song2.m4a', cover: '/Wuhlan3/img/song2.jpg' } - { name: '奇迹の山', artist: '岸部真明', url: '/Wuhlan3/mp3/song3.m4a', cover: '/Wuhlan3/img/song2.jpg' } - { name: 'Sunflower', artist: '孙培博', url: '/Wuhlan3/mp3/song5.mp3', cover: '/Wuhlan3/img/song3.jpg' } - { name: '少年の梦', artist: '岸部真明', url: '/Wuhlan3/mp3/song4.m4a', cover: '/Wuhlan3/img/song2.jpg' } - { name: 'like a star', artist: 'Youngso Kim', url: '/Wuhlan3/mp3/like a star.mp3', cover: '/Wuhlan3/img/like a star.jpg' } - { name: '境', artist: '刘嘉卓', url: '/Wuhlan3/mp3/境.mp3', cover: '/Wuhlan3/img/刘嘉卓.jpg' } - { name: '翼~you are the HERO~', artist: '押尾コータロー', url: '/Wuhlan3/mp3/wings.mp3', cover: '/Wuhlan3/img/押尾.jpg' }
|
只需要稍微修改一下参数就🆗
啦,当然,我们会发现,播放器小框框一直显示在左下角,很碍眼。
通过该路径:\blog\themes\hexo-theme-fluid\source\css,新建一个文件custom.css,在里面放下这段代码即可。
1 2 3 4 5 6 7 8 9
| .aplayer.aplayer-fixed.aplayer-narrow .aplayer-body { left: -66px !important; }
.aplayer.aplayer-fixed.aplayer-narrow .aplayer-body:hover { left: 0 !important; }
|
四、添加动态效果
添加动态效果的方法非常简单,在_config.yml中找到该代码块:
1 2 3 4 5
| custom_js: # 指定自定义 js 文件路径,路径是相对 source 目录,如 /js/custom.js 对应存放目录 source/js/custom.js,支持列表 - /js/dongtaicaidai.js # 动态彩带 # - /js/bubble.js #头部上升气泡 #- #-
|
可以直接按照格式调用JS代码,也可以通过本地的路径来调用JS代码
分享一个小仓库:https://cdn.jsdelivr.net/gh/bynotes/texiao@latest/source/js/
五、给Fluid添加一言
首先,我们如何进行句子的筛选呢?
句子类型(参数)
| a |
动画 |
| b |
漫画 |
| c |
游戏 |
| d |
文学 |
| e |
原创 |
| f |
来自网络 |
| g |
其他 |
| h |
影视 |
| i |
诗词 |
| j |
网易云 |
| k |
哲学 |
| l |
抖机灵 |
| 其他 |
作为 动画 类型处理 |
可选择多个分类,例如: ?c=a&c=c
最终我是用的是"https://v1.hitokoto.cn?c=i&max_length=20"
之后,我们只需要修改_config.yml就可以设置slogan为一言:
1 2 3 4 5 6 7 8 9
| slogan: enable: true text: '少年何妨梦摘星,敢挽桑弓射玉衡' api: enable: true url: "https://v1.hitokoto.cn?c=i&max_length=20" method: "GET" headers: {} keys: ['hitokoto']
|
但是这样子限制得比较死,且只能够打印出诗句,而没有诗人和出处。可以通过修改typed.ejs来解决。该文件位于hexo-theme-fluid\layout\_partials\plugins\typed.ejs,修改为如下代码:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
| <% if(theme.fun_features.typing.enable && in_scope(theme.fun_features.typing.scope) && page.subtitle !== false) { %> <%- js_ex(theme.static_prefix.typed, '/typed.min.js') %> <script> (function (window, document) { var typing = Fluid.plugins.typing; var subtitle = document.getElementById('subtitle'); if (!subtitle || !typing) { return; } var text = subtitle.getAttribute('data-typed-text'); <% if (is_home() && theme.index.slogan.api && theme.index.slogan.api.enable) { %> jQuery.ajax({ type: '<%= theme.index.slogan.api.method %>', url: '<%- theme.index.slogan.api.url %>', headers: <%- JSON.stringify(theme.index.slogan.api.headers || {}) %>, dataType: 'json', success: function(result) { var apiText; var hitokoto = '少年何妨梦摘星,敢挽桑弓射玉衡'; var from = ''; var from_who = ''; if (result) { var keys = '<%= theme.index.slogan.api.keys %>'.split(','); if (result instanceof Array) { result = result[0]; } for (const k of keys) { var value = result[k]; if (typeof value === 'string'){ if(k == 'hitokoto'){ hitokoto = value } else if (k == 'from'){ from = value } else if (k == 'from_who'){ from_who = value } } } if(from == '' || from_who == ''){ apiText = `${hitokoto}` } else { apiText = `${hitokoto}<br>——${from_who}《${from}》` } } apiText ? typing(apiText) : typing(text); }, error: function(xhr, status, error) { if (error) { console.error('Failed to request <%= theme.index.slogan.api.url %>:', error); } typing(text); } }) <% } else { %> typing(text); <% } %> })(window, document); </script> <% } %>
|
这里,我修改了keys的用法,所以_config.yml文件中的keys也要相应改变:
1 2 3 4 5 6 7 8 9
| slogan: enable: true text: '少年何妨梦摘星,敢挽桑弓射玉衡' api: enable: true url: "https://v1.hitokoto.cn?c=i&max_length=20" method: "GET" headers: {} keys: ['hitokoto', 'from', 'from_who']
|
六、对文章进行加密
加入这个功能,会不会违背写博客这个初心呢?
1 2
| //安装插件 yarn add hexo-blog-encrypt
|
修改配置文件
在文章开头加入一些信息
1 2 3 4
| password: XXXXXX message: 嘻嘻,有密码才能看喔 excerpt: 旧的文章概要 abstract: 新的文章概要
|