mirror of
https://github.com/next-theme/hexo-theme-next.git
synced 2026-01-18 18:33:42 +00:00
Fix json filter
* See: https://github.com/next-theme/hexo-theme-next/issues/13
This commit is contained in:
parent
2b7a638c8d
commit
4013450403
@ -15,7 +15,10 @@ function njkCompile(data) {
|
||||
return dictionary;
|
||||
});
|
||||
env.addFilter('json', dictionary => {
|
||||
return JSON.stringify(dictionary || '');
|
||||
if (typeof dictionary !== 'undefined' && dictionary !== null) {
|
||||
return JSON.stringify(dictionary);
|
||||
}
|
||||
return '""';
|
||||
});
|
||||
return nunjucks.compile(data.text, env, data.path);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user