0%

Hexo 可以使用以下命令打印所有的 category以及其所关联的文章数目,但是并不支持以层级结构打印 category 之间的关系。

1
hexo list category

可以根据 Hexo官方API文档,编写脚本来扩展这个需求:

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
const Hexo = require('hexo');

const build_category_tree = (categories, parent='') => {
let {filtered: sub_categories, excluded: remain} = categories.reduce(
(result, category) => {
if ('parent' in category && category['parent'] != parent) {
result.excluded.push(category);
} else {
result.filtered.push(category);
}
return result;
},
{filtered: [], excluded: []}
);

sub_categories.sort((l, r) => {
if (l.name < r.name) {
return -1;
} else if (l.name > r.name) {
return 1;
} else {
return 0;
}
});

return sub_categories.map(category => {
return {
name: category.name,
subs: build_category_tree(remain, category._id)
}
});
};

const show_category_tree = (category_tree, prefix='') => {
category_tree.forEach(item => {
console.log(prefix + '|-' + item.name);
show_category_tree(item.subs, prefix + '| ');
});
};

(async function() {
let hexo = new Hexo(process.cwd(), {});

await hexo.init();
await hexo.load();

show_category_tree(build_category_tree(hexo.locals.get('categories').toArray()));
})();

该脚本打印的样式如下:

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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|-Algorithm
| |-Smooth
|-C
| |-Attribute
| |-宏
| | |-函数签名
| |-性能优化
|-C++
| |-Attribute
| |-宏
| | |-函数签名
| |-性能优化
| |-编码规范
| |-编码风格
|-CI/CD
| |-Github Actions
|-Chrome
| |-Plugin
|-Clang-Format
| |-C++
|-Database
| |-Mysql
| | |-Table
|-DirectX
| |-坐标系
|-Docker
| |-Image
| |-Mirror
| |-Volume
| | |-Bind Mount
|-FFmpeg
| |-动画拼接
|-Hack
| |-Game
| | |-Mod
| | | |-Elden Ring
|-Hexo
| |-Category
| |-Deploy
| |-Draft
| |-Markdown
| | |-Footnote
| |-Page
|-Hook
| |-frida
|-Linux
| |-Command
| | |-File System
| | |-Service
| |-Kernel
| | |-性能优化
| |-Proxy
| |-包管理工具
| | |-yum
| |-发行版
| | |-Alpine
| | | |-Mirror
| |-命令
| | |-运维相关
| |-源码阅读
| | |-源码目录结构
| |-网络
| | |-防火墙
|-Lua
| |-C++
| |-Plugin
|-Mac OS
| |-包管理器
| | |-brew
| | | |-FAQ
| |-服务
| | |-ssh
|-Node.js
| |-Npm
| | |-Mirror
| |-框架
| | |-Web
| | | |-express.js
| | | | |-Session
|-Objective-C
| |-GNUstep
| | |-环境搭建
|-Python
| |-List
| |-pyd
| | |-boost::python
| | | |-callback
| |-依赖处理
| |-字符串处理
| |-异常处理
|-Qt
| |-QtWebEngine
|-Skia
| |-编译
|-Visual Studio
| |-Command Window
| |-Python
| | |-pyd
|-Windows
| |-Explorer
| |-Network
| | |-URL Protocol
| |-PE
| |-VBScript
| | |-Shell
| |-文件共享
| |-网络
| | |-代理
| | |-屏蔽端口
| | |-端口转发
|-apt
|-golang
| |-mirror
|-shellcode
| |-shell
|-windows
| |-安全
| | |-勒索病毒
|-微服务
| |-容错机制
|-构建工具
| |-meson
| | |-backend
| | | |-Visual Studio
| | |-custom target
| | |-setup
|-版本控制
| |-Git
| | |-Bug定位
| | |-Commit
| | |-Config
| | |-Conflict
| | |-Git Flow
| | |-Merge
| | |-Push
| |-版本号
|-虚拟化
| |-网络配置
|-软件工程
|-软件破解
|-运维
|-逆向分析
|-项目日志
| |-Link-Cooperation
| | |-敏捷过程

如果 brew 在下包时出现如下证书无效问题:

1
curl: (60) SSL certificate problem: Invalid certificate chain

可以通过指定 --insecure 临时忽略该问题:

1
2
3
# HOMEBREW_CURLRC=1可以让brew命令在执行curl时忽略证书验证
echo insecure >> ~/.curlrc
export HOMEBREW_CURLRC=1

1
2
3
4
5
# 启动ssh服务
sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

# 允许远程登陆
sudo systemsetup -setremotelogin on

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
@echo off

echo 关闭445端口与相关服务
sc stop lanmanserver >nul 2>&1
sc config lanmanserver start= disabled >nul 2>&1

echo 关闭135端口与相关服务
reg add HKLM\SOFTWARE\Microsoft\Rpc /v "DCOM Protocols" /t REG_MULTI_SZ /d "" /f >nul 2>&1
reg add HKLM\SOFTWARE\Microsoft\Rpc\Internet /f >nul 2>&1

echo 添加IPSec安全策略,过滤不安全的端口

REM 删除旧的策略
netsh ipsec static delete policy name=SECGUEST >nul 2>&1

REM 禁用危险端口
netsh ipsec static add policy name=SECGUEST >nul 2>&1
netsh ipsec static add filteraction name=Block action=block >nul 2>&1
netsh ipsec static add filterlist name=SECCPF >nul 2>&1
netsh ipsec static add filter filterlist=SECCPF srcaddr=Any dstaddr=Me dstport=135 protocol=TCP >nul 2>&1
netsh ipsec static add filter filterlist=SECCPF srcaddr=Any dstaddr=Me dstport=445 protocol=TCP >nul 2>&1
netsh ipsec static add rule name=SECCPR policy=SECGUEST filterlist=SECCPF filteraction=Block >nul 2>&1
netsh ipsec static set policy name=SECGUEST assign=y >nul 2>&1

echo 关闭并删掉与mssecsvr.exe相关服务与文件
sc stop mssecsvc2.1 >nul 2>&1
sc config mssecsvc2.1 start= disabled >nul 2>&1
sc delete mssecsvc2.1 >nul 2>&1
for /f "tokens=2,3*" %%i in ('tasklist ^| findstr "tasksche.exe"') do (@taskkill /pid %%i /f)
for /f "tokens=2,3*" %%i in ('tasklist ^| findstr "mssecsvr.exe"') do @set mssecsvr_pid=%%i >nul 2>&1
if defined mssecsvr_pid (echo mssecsvr.exe's pid : %mssecsvr_pid% && taskkill /pid %mssecsvr_pid% /f) else (echo mssecsvr.exe未启动)

REM 删除mssecsvr.exe,tasksche.exe,qeriuwjhrf
REM del c:\windows\tasksche.exe
REM del c:\windows\mssecsvr.exe
REM del c:\windows\qeriuwjhrf

pause