hexo-blog-encrypt
插件就能很好地解决这个问题.default
, xray
], 更多的主题正在开发中.hello
.npm install --save hexo-blog-encrypt
或yarn add hexo-blog-encrypt
(需要Yarn)
---
title: Hello World
date: 2016-03-30 21:18:02
password: hello
---
hexo clean && hexo g && hexo s
在本地预览加密的文章.文章信息头 > 按标签加密
---
title: Hello World
tags:
- 作为日记加密
date: 2016-03-30 21:12:21
password: mikemessi
abstract: 有东西被加密了, 请输入密码查看.
message: 您好, 这里需要密码.
wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试.
wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.
---
_config.yml
# Security
encrypt: # hexo-blog-encrypt
abstract: 有东西被加密了, 请输入密码查看.
message: 您好, 这里需要密码.
tags:
- {name: tagName, password: 密码A}
- {name: tagName, password: 密码B}
wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试.
wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.
只需要将博文头部的 password
设置为 ""
即可取消 Tag 加密.
Example:
---
title: Callback Test
date: 2019-12-21 11:54:07
tags:
- A Tag should be encrypted
password: ""
---
Use a "" to diable tag encryption.
文章信息头 > _config.yml
(站点根目录下的) > 默认配置
在部分博客中, 解密后部分元素可能无法正常显示或者表现, 这属于已知问题. 目前的解决办法是通过自行查阅自己的博客中的代码, 了解到在 onload 事件发生时调用了哪些函数, 并将这些函数挑选后写入到博客内容中. 如:
---
title: Callback Test
date: 2019-12-21 11:54:07
tags:
- Encrypted
---
This is a blog to test Callback functions. You just need to add code at the last of your post like following:
It will be called after the blog decrypted.
例子在: Callback 例子.
如果你有一篇文章使用了 TOC,你需要修改模板的部分代码。这里用 landscape 作为例子:
<% if(post.toc == true){ %>
style="display:none" <% } %>>
Index
<% if (post.encrypt == true) { %>
<%- toc(post.origin, {list_number: true}) %>
<% } else { %>
<%- toc(post.content, {list_number: true}) %>
<% } %>
<% } %>
<%- post.content %>
If you want to disable the logging, you can add a silent property in _config.yml
and set it to true. 如果你想要禁止使用 Log, 你可以在 _config.yml
中增加一个 silent 属性, 并将其设置为 true.
# Security
encrypt: # hexo-blog-encrypt
silent: true
这样就会禁止如 INFO hexo-blog-encrypt: encrypting "{Blog Name}" based on Tag: "EncryptedTag".
的日志.
之前, 我们尝试使用 template
关键字来让用户能修改自己的主题. 后来发现真不是一个好主意. 所以我们现在引入了主题: theme
关键字.
你可以简单的使用 theme
在 _config.yml
里或者文章头, 如下:
---
title: Hello World
tags:
- 作为日记加密
date: 2016-03-30 21:12:21
password: mikemessi
abstract: 有东西被加密了, 请输入密码查看.
message: 您好, 这里需要密码.
theme: xray
wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试.
wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.
---
_config.yml
# Security
encrypt: # hexo-blog-encrypt
abstract: 有东西被加密了, 请输入密码查看.
message: 您好, 这里需要密码.
tags:
- {name: tagName, password: 密码A}
- {name: tagName, password: 密码B}
theme: xray
wrong_pass_message: 抱歉, 这个密码看着不太对, 请再试试.
wrong_hash_message: 抱歉, 这个文章不能被校验, 不过您还是能看看解密后的内容.
你可以在线挑选你喜欢的主题,并应用到你的博客中:
hexo-blog-encrypt仓库地址:https://github.com/D0n9X1n/hexo-blog-encrypt/