From 6b0b772b999e29cd046b87bdd05e9dfd4c1bfe1f Mon Sep 17 00:00:00 2001 From: Benji Encalada Mora Date: Wed, 30 Oct 2019 13:25:58 -0500 Subject: [PATCH] Add filter for HTML content --- .eleventy.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.eleventy.js b/.eleventy.js index 1d3dbc1..2f610c6 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -19,6 +19,16 @@ module.exports = function(eleventyConfig) { return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); }); + // 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, '\\"'); + } + return content; + }); + // Get the first `n` elements of a collection. eleventyConfig.addFilter("head", (array, n) => { if( n < 0 ) {