Skip to content

Commit

Permalink
Bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
D0n9X1n committed Sep 15, 2019
1 parent 0775e04 commit 658e76f
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ hexo.extend.filter.register('after_post_render', (data) => {

let password = data.password;

if (hexo.config.encrypt === undefined) {

This comment has been minimized.

Copy link
@xiazeyu

xiazeyu Sep 16, 2019

Collaborator

这句和('encrypt' in hexo.config)有什么区别吗orz
然后这里直接hexo.config.encrypt = hexo.config.encrypt||[];就可以了..

hexo.config.encrypt = [];
}

if(('encrypt' in hexo.config) && ('tags' in hexo.config.encrypt)){
hexo.config.encrypt.tags.forEach((tagObj) => {
tagEncryptName.push(tagObj.name);
Expand All @@ -48,32 +52,34 @@ hexo.extend.filter.register('after_post_render', (data) => {
// make sure toc can work.
data.origin = data.content;

// Let's rock n roll
const config = Object.assign(defaultConfig, hexo.config.encrypt, data);

// --- Begin --- Remove in the next version please
// ------------
// Remove in v3.1.0
const deprecatedConfigs = [
'default_template',
'default_abstract',
'default_message',
'default_decryption_error',
'default_no_content_error',
];
const defaultConfigs = [
const configKeys = [
'template',
'abstract',
'message',
'wrong_pass_message',
'wrong_hash_message',
]
];

deprecatedConfigs.forEach((key, index) => {
if(key in config){
log.warn(`hexo-blog-encrypt: "${key}" is DEPRECATED, please change to newer API: "${defaultConfigs[index]}"`);
config[defaultConfigs[index]] = config[key];
if(key in hexo.config.encrypt) {
log.warn(`hexo-blog-encrypt: "${key}" is DEPRECATED, please change to newer API: "${configKeys[index]}"`);
hexo.config.encrypt[configKeys[index]] = hexo.config.encrypt[key];
}
});
// ------------

// Let's rock n roll
const config = Object.assign(defaultConfig, hexo.config.encrypt, data);

// --- End --- Remove in the next version please
log.info(`hexo-blog-encrypt: encrypting "${data.title.trim()}" with password "${password}".`);

data.content = data.content.trim();
Expand Down

0 comments on commit 658e76f

Please sign in to comment.