Rename json to safedump

This commit is contained in:
Mimi 2020-06-30 12:05:18 +08:00
parent 53a220f398
commit 19054432ba
7 changed files with 11 additions and 11 deletions

View File

@ -6,7 +6,7 @@
<script{{ pjax }} id="page-configurations"> <script{{ pjax }} id="page-configurations">
// https://hexo.io/docs/variables.html // https://hexo.io/docs/variables.html
CONFIG.page = { CONFIG.page = {
sidebar: {{ page.sidebar | json }}, sidebar: {{ page.sidebar | safedump }},
isHome : {{ is_home() }}, isHome : {{ is_home() }},
isPost : {{ is_post() }}, isPost : {{ is_post() }},
lang : '{{ page.lang }}' lang : '{{ page.lang }}'

View File

@ -12,7 +12,7 @@
}; };
// Read config form theme config file // Read config form theme config file
Object.assign(calendar, {{ theme.calendar | json }}); Object.assign(calendar, {{ theme.calendar | safedump }});
var now = new Date(); var now = new Date();
var timeMax = new Date(); var timeMax = new Date();

View File

@ -13,9 +13,9 @@
{%- if page.comments %} {%- if page.comments %}
<script> <script>
var disqus_config = function() { var disqus_config = function() {
this.page.url = {{ page.permalink | json }}; this.page.url = {{ page.permalink | safedump }};
this.page.identifier = {{ page.path | json }}; this.page.identifier = {{ page.path | safedump }};
this.page.title = {{ page.title | json }}; this.page.title = {{ page.title | safedump }};
{% if __('disqus') !== 'disqus' -%} {% if __('disqus') !== 'disqus' -%}
this.language = '{{ __('disqus') }}'; this.language = '{{ __('disqus') }}';
{% endif -%} {% endif -%}

View File

@ -11,9 +11,9 @@ NexT.utils.loadComments(document.querySelector('#disqus_thread'), () => {
api : '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/', api : '{{ theme.disqusjs.api }}' || 'https://disqus.com/api/',
apikey : '{{ theme.disqusjs.apikey }}', apikey : '{{ theme.disqusjs.apikey }}',
shortname : '{{ theme.disqusjs.shortname }}', shortname : '{{ theme.disqusjs.shortname }}',
url : {{ page.permalink | json }}, url : {{ page.permalink | safedump }},
identifier: {{ page.path | json }}, identifier: {{ page.path | safedump }},
title : {{ page.title | json }}, title : {{ page.title | safedump }},
}); });
}, window.DisqusJS); }, window.DisqusJS);
}); });

View File

@ -6,7 +6,7 @@ NexT.utils.loadComments(document.querySelector('#valine-comments'), () => {
new Valine(Object.assign({ new Valine(Object.assign({
el : '#valine-comments', el : '#valine-comments',
path: location.pathname, path: location.pathname,
}, {{ theme.valine | json }} }, {{ theme.valine | safedump }}
)); ));
}, window.Valine); }, window.Valine);
}); });

View File

@ -61,7 +61,7 @@
}); });
} }
let { app_id, app_key, server_url } = {{ theme.leancloud_visitors | json }}; let { app_id, app_key, server_url } = {{ theme.leancloud_visitors | safedump }};
function fetchData(api_server) { function fetchData(api_server) {
var Counter = (method, url, data) => { var Counter = (method, url, data) => {
return fetch(`${api_server}/1.1${url}`, { return fetch(`${api_server}/1.1${url}`, {

View File

@ -10,7 +10,7 @@ function njkCompile(data) {
const env = nunjucks.configure(templateDir, { const env = nunjucks.configure(templateDir, {
autoescape: false autoescape: false
}); });
env.addFilter('json', dictionary => { env.addFilter('safedump', dictionary => {
if (typeof dictionary !== 'undefined' && dictionary !== null) { if (typeof dictionary !== 'undefined' && dictionary !== null) {
return JSON.stringify(dictionary); return JSON.stringify(dictionary);
} }