Blog_Building_Log
这几日打算再优化优化博客,但有的功能就是思来想去无从下手,一看官网竟然有插件实现了想要的功能,遂将从前自己实现的功能都查了查,发现都有对应实现!想想已然被我改的面目全非的布局、配置文件,决定重新构建一下博客环境,并尽可能使用插件实现功能。当然,日志是必要的,不然但我发现博客环境发生问题时,就无处下手了。
界面调控
对Next主题的显示内容,如邮箱等内容进行了设置
Live2d!
Live2d用到了插件live2d-widget,需按照以下指令进行安装:
1 | # 安装插件 |
并在Hexo配置文件中添加如下配置:
1 | #二次元 |
搜索
添加搜索功能分为两个部分,1)开启hexo的搜索功能2)在主题中开启搜索入口
1 | # 1)开启hexo的搜索功能 |
1 | # 2)Next主题下,开启入口 |
主页生成器
通过插件hexo-generator-index-custom,生成主页,并实现hide与top功能
1 | # 卸载自带的 |
1 | index_generator: |
自动目录化
使用hexo-auto-category插件实现更具博客路径生成目录。首先安装插件。
1 | npm install hexo-auto-category --save |
然后在hexo的配置文件中写入如下配置:
1 | # Generate categories from directory-tree |
添加目录与标签
目录与标签功能无需另外安装插件,直接配置启用即可。
首先建立新Page
1 | hexo new page categories |
修改其内容,设置type属性
1 | # categories/index.md |
1 | # categories/index.md |
markdown绘图支持
我们常常使用markdown中的mermaid进行一些流程图、UML图的绘制,这在hexo中需要hexo-filter-mermaid-diagrams插件支持。
1 | npm install hexo-filter-mermaid-diagrams --save |
1 | # mermaid chart |
文件结构管理
最开始写hexo博客时,我按照hexo的默认设置,将所有博客直接存放在source/_post文件夹下。时间长了,博客大量堆积,再加之每篇博客都有对应的资源文件夹,_post文件夹下变得混乱不堪,难以寻址。于是,我计划对博客的源文件位置进行从新编排。
过程中用到一个插件:
- hexo-auto-category: 根据文章所在文件夹自动设置目录
然后,对生成文件路径进行配置:
首先修改permalink,这边以所属目录为根目录,保证服务器文件的简洁性,另外后续使用post_title,而非title,避免源文件的相对路径影响到服务器文件的相对路径。
1 | permalink: :category/:post_title/ |
然后,再修改new_post_name为:title/:title.md。这样可以生成如下文件结构:
- title:
- title-assets
- title.md
可以保证博客的资源文件与博客文件存储在博客名下的文件夹内,避免分离。
1 | new_post_name: :title/:title.md |
Next部分
在next部分中,我们可以对next主题界面中的元素进行更改与修饰。
Menu
在menu中,可以通过配置theme配置文件添加新的选项——Game、Academic、Photos等等。
如下,我们添加了一个选项game,将其连接至根目录/,并附加图标fa fa-gamepad——此处图标来源于FontAwesome。
1 | menu: |