From 401345040333e2975d415b3a6b2058f25369bd43 Mon Sep 17 00:00:00 2001 From: Mimi <1119186082@qq.com> Date: Fri, 29 May 2020 19:54:21 +0800 Subject: [PATCH] Fix json filter * See: https://github.com/next-theme/hexo-theme-next/issues/13 --- scripts/renderer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/renderer.js b/scripts/renderer.js index 28e5079..9dbef15 100644 --- a/scripts/renderer.js +++ b/scripts/renderer.js @@ -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); }