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
|
||||
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.
|
||||
|
@ -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 %}
|
||||
|
Loading…
Reference in New Issue
Block a user