Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Quick Start

Create a new post

1
$ hexo new "My New Post"

More info: Writing

Run server

1
$ hexo server

More info: Server

Generate static files

1
$ hexo generate

More info: Generating

Deploy to remote sites

1
$ hexo deploy

More info: Deployment

Nodejs and NPM requirement

Nodejs higher than 6.0.0 and NPM higher than 5. Otherwise, Hexo might not work with some strange error!!

Hexo Mermaid for graph

More info: Here

  • Flow chart
    graph TD;
      A-->B;
      A-->C;
      B-->D;
      C-->D;
graph TD;
    交易合同TradeContract--contains-->仓位Position;
    仓位Position--scales-->资产Asset;
    资产Asset--references-->价值的票据InstrumentOfValue;
  • Gannt diagram
gantt
    dateFormat  YYYY-MM-DD
    title       Adding GANTT diagram functionality to mermaid
    excludes    weekends
    %% (`excludes` accepts specific dates in YYYY-MM-DD format, days of the week ("sunday") or "weekends", but not the word "weekdays".)

    section A section
    Completed task            :done,    des1, 2014-01-06,2014-01-08
    Active task               :active,  des2, 2014-01-09, 3d
    Future task               :         des3, after des2, 5d
    Future task2              :         des4, after des3, 5d

    section Critical tasks
    Completed task in the critical line :crit, done, 2014-01-06,24h
    Implement parser and jison          :crit, done, after des1, 2d
    Create tests for parser             :crit, active, 3d
    Future task in critical line        :crit, 5d
    Create tests for renderer           :2d
    Add to mermaid                      :1d

    section Documentation
    Describe gantt syntax               :active, a1, after des1, 3d
    Add gantt diagram to demo page      :after a1  , 20h
    Add another diagram to demo page    :doc1, after a1  , 48h

    section Last section
    Describe gantt syntax               :after doc1, 3d
    Add gantt diagram to demo page      :20h
    Add another diagram to demo page    :48h

Hexo simple mindmap

Hexo simple mindmap插件提供了对脑图的可视化支持,相较于mermaid插件的流程图,能够提供更加原生的脑图体验。

More info:here

  • Example
  • 软件架构师思维导图
    • 代码规范
      • 设计模式
      • 重构
      • 源码学习与分析
      • 复杂系统面向对象模型设计

Hexo search功能

随着文章数量增加,每一页寻找文档变得耗时间,所以增加了search功能来支持快速文章定位功能。

More info: here

  1. 下载插件
1
npm install hexo-generator-searchdb --save
  1. 配置_config.yaml文件( “hexo-generator-searchdb”: “^1.4.1”后需要更新配置)
1
2
3
4
5
6
search:
path: search.xml
field: post
content: true
format: html

  1. 配置next主题的_config.yaml文件
1
2
3
4
5
6
7
8
9
# Local search
# Dependencies: https://github.com/flashlab/hexo-generator-search
local_search:
enable: true
# if auto, trigger search by changing input
# if manual, trigger search by pressing enter key or search button
trigger: auto
# show top n results per article, show all results by setting to -1
top_n_per_article: 1

hexo UML图绘制

顺序图(Sequence Diagram)

类图(Class Diagram)

  1. 强耦合关系
  1. 弱耦合关系

Hexo post asset image 管理

  1. 自带的hexo-renderer-marked的postAsset无法正常工作
  2. 使用hexo-asset-link可以动态生成基于post_dir的图片link,同时在local/remote正常工作
  3. 不要在code中写入encoded path或者linux slash /,虽然预览没有问题,但是生成的Link会出问题

Hexo blog encrypt 支持TOC

  1. 完美修复
    https://www.itfanr.cc/2021/04/16/hexo-blog-article-encryption/

  2. UX修复

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

# node_modules\hexo-theme-next\layout\_macro\sidebar.njk

{%- if display_toc %}
{%- if (page.encrypt) %}
{%- set toc = toc(page.origin, { class: "nav", list_number: page.toc.number, max_depth: page.toc.max_depth }) %}
{%- else %}
{%- set toc = toc(page.content, { class: "nav", list_number: page.toc.number, max_depth: page.toc.max_depth }) %}
{%- endif %}
{%- set display_toc = toc.length > 1 and display_toc %}
{%- endif %}

<!--noindex-->
<div class="post-toc-wrap sidebar-panel">
{%- if display_toc %}
<!--- For hide TOC in encryption -->
{%- if (page.encrypt) %}
<div id="toc-div" style="display:none">
{%- else %}
<div id="toc-div">
{%- endif %}
<div class="post-toc animated">{{ toc }}</div>
</div><!-- end of hide -->
{%- endif %}
</div>
<!--/noindex-->

hexo 将category作为目录归类博客

当文件数量已经比较多,单层级目录很难去管理文章分类。用hexo-directory-category 可以较好的管理post文档,便于源文件查找和更新。

hexo-next-pwa,支持页面离线访问

PWA应用的创建包含两部分,一个是manifest.json文件放在source目录下,用于提示浏览器安装PWA应用。一个是sw.js文件,用hexo workbox命令生成并注册到index.html文件,使应用支持离线访问,在线更新功能。

PWA应用的好处是运用sw.js文件,在浏览器启动一个类似原生应用的app,加载初始页面,在没有网的情况下访问离线页面,有网的情况下可以选择优先加载。对于静态页面的应用具有提升加载速度的好处。