use JSON.stringify for content

master
Benji Encalada Mora 2020-01-20 01:26:45 -06:00
parent fb7383c3ed
commit 12219c480f
No known key found for this signature in database
GPG Key ID: DBEBBE9A2EB76EEB
2 changed files with 5 additions and 7 deletions

View File

@ -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.

View File

@ -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 %}