use JSON.stringify for content
This commit is contained in:
parent
fb7383c3ed
commit
12219c480f
10
.eleventy.js
10
.eleventy.js
@ -20,13 +20,11 @@ module.exports = function(eleventyConfig) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Content for jsonfeed
|
// Content for jsonfeed
|
||||||
eleventyConfig.addFilter('jsonContent', content => {
|
eleventyConfig.addFilter('jsonStringify', content => {
|
||||||
if (content) {
|
if (!content) {
|
||||||
content = content.replace(/(\r\n|\n|\r)/gm, "");
|
content = "";
|
||||||
content = content.replace(/\t/g, "\\t");
|
|
||||||
content = content.replace(/"/g, '\\"');
|
|
||||||
}
|
}
|
||||||
return content;
|
return JSON.stringify(content);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Get the first `n` elements of a collection.
|
// Get the first `n` elements of a collection.
|
||||||
|
@ -19,7 +19,7 @@ eleventyExcludeFromCollections: true
|
|||||||
"id": "{{ absolutePostUrl }}",
|
"id": "{{ absolutePostUrl }}",
|
||||||
"url": "{{ absolutePostUrl }}",
|
"url": "{{ absolutePostUrl }}",
|
||||||
"title": "{{ post.data.title }}",
|
"title": "{{ post.data.title }}",
|
||||||
"content_html": "{{ post.templateContent | jsonContent | safe }}",
|
"content_html": {{ post.templateContent | jsonStringify | safe }},
|
||||||
"date_published": "{{ post.date | rssDate }}",
|
"date_published": "{{ post.date | rssDate }}",
|
||||||
"tags": [
|
"tags": [
|
||||||
{%- for c in post.data.category %}
|
{%- for c in post.data.category %}
|
||||||
|
Loading…
Reference in New Issue
Block a user