diff --git a/.eleventy.js b/.eleventy.js index 2f610c6..77c9143 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -20,13 +20,11 @@ module.exports = function(eleventyConfig) { }); // Content for jsonfeed - eleventyConfig.addFilter('jsonContent', content => { - if (content) { - content = content.replace(/(\r\n|\n|\r)/gm, ""); - content = content.replace(/\t/g, "\\t"); - content = content.replace(/"/g, '\\"'); + eleventyConfig.addFilter('jsonStringify', content => { + if (!content) { + content = ""; } - return content; + return JSON.stringify(content); }); // Get the first `n` elements of a collection. diff --git a/feed/json.njk b/feed/json.njk index 85200d0..97e0841 100644 --- a/feed/json.njk +++ b/feed/json.njk @@ -19,7 +19,7 @@ eleventyExcludeFromCollections: true "id": "{{ absolutePostUrl }}", "url": "{{ absolutePostUrl }}", "title": "{{ post.data.title }}", - "content_html": "{{ post.templateContent | jsonContent | safe }}", + "content_html": {{ post.templateContent | jsonStringify | safe }}, "date_published": "{{ post.date | rssDate }}", "tags": [ {%- for c in post.data.category %}