起因

不知是哪位勇士把学校端了,我们的寒假得以续命几天。

只是阴差阳错地把自己的笔记本给拆了,风扇叶片清灰的时候折了。经测试,噪音巨大。

不过最近的话要给它升级CPU,所以我就没把它拼回去,风扇也重新买了一个。大概等到5号的时候就能装回去了。

在此之前,如果要更新博客,只能使用另一种设备了。

┐(‘~`;\)┌

正文

其实使用手机写博客的大概方法还是在建站初从某个技术交流群里的叫作WMZ的小老弟那里得到的。原理很简单,在Android上面搭建一个Linux的环境,再安装node.js和hexo。

需要用到的东西

软件商店:

  • Google Play Store
  • 飞机或者梯子 (懂的都懂)

当然,在国内某些第三方平台也可以找到,但费时费力。

环境:

  • Termux(可在Google Play Store中下载安装)

编辑器(可选):

  • Markor(可在Google Play Store中下载安装)

配置apt源

在第一次启动时,Termux需要安装基本组件。此时没有对/storage/emulated/0的访问权限。可在应用程序设置中赋予其储存空间权限,也可以通过执行命令termux-setup-storage获取。

rt.

Termux使用的是dpkg包管理器。但和原生debian相比,配置Termux的包管理要相对麻烦。

这里使用的是清华的镜像站,帮助文档在此处

博客环境

hexo需要node.js才能运行。我们也需要git将博客静态页上传。

1
pkg install nodejs-lts git -y

测试:

1
2
~ $ node -v
v12.18.3

现在就可以安装hexo了。为提高速度,我们也需要配置国内的淘宝npm源,再安装hexo。

1
2
3
npm config set registry https://registry.npm.taobao.org
npm i -g express
npm install hexo-cli -g

测试:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
~ $ hexo version
hexo-cli: 4.2.0
os: Linux 3.18.66-perf-g398a6a2ffc46 android arm64
node: 12.18.3
v8: 7.8.279.23-node.39
uv: 1.38.0
zlib: 1.2.11
brotli: 1.0.7
ares: 1.16.1
modules: 72
nghttp2: 1.41.0
napi: 6
llhttp: 2.0.4
http_parser: 2.9.3
openssl: 1.1.1h
cldr: 37.0
icu: 67.1
tz: 2019c
unicode: 13.0

博客

通过某种手段(sftp/samba/dropbox/百度网盘)将之前的博客数据转移到手机上。

进入博客目录,使用命令hexo s测试。

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
.../0/Minus-K $ hexo s
INFO Validating config
INFO
===================================================================


##### # # ##### ##### ###### ##### ###### # # #
# # # # # # # # # # # # #
##### # # # # ##### # # ##### # #
# # # # # # # ##### # # #
# # # # # # # # # # # #
##### #### # # ###### # # # ###### #

3.5.1
===================================================================
INFO Start processing
INFO Generate link [437b4571] for post [source/_posts/关于我用手机更新hexo博客这件事情.md][ 关于我用手机更新hexo博客这件事情 ]
INFO Generated: categories [日常宅技术] for post [source/_posts/关于我用手机更新hexo博客这件事情.md][ 关于我用手机更新hexo博客这件事情 ]
/storage/emulated/0/Minus-K/source/_data/bangumis.json
INFO 75 bangumis have been loaded
INFO Generating Baidu urls for last 3 posts
INFO Posts urls generated in baidu_urls.txt
https://www.kawashiros.club/p/2021/437b4571.html
https://www.kawashiros.club/p/2021/1aa35a5.html
https://www.kawashiros.club/p/2021/d74d746c.html
INFO Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
/storage/emulated/0/Minus-K/source/_data/bangumis.json
INFO 75 bangumis have been loaded
INFO Generating Baidu urls for last 3 posts
INFO Posts urls generated in baidu_urls.txt
https://www.kawashiros.club/p/2021/437b4571.html
https://www.kawashiros.club/p/2021/1aa35a5.html
https://www.kawashiros.club/p/2021/d74d746c.html

此时访问127.0.0.1:4000,若正常显示博客页面,那么就说明你可以开始撰写文章了。

我之前使用github pagse托管而通过ssh上传静态页面,因为是临时使用所以在博客_config.yml中将ssh换为https上传。

撰写文章

hexo new post

使用markor编辑

参考