From d3ced37f505f767a2780635199d6f55da6f1581a Mon Sep 17 00:00:00 2001 From: Zach Leatherman Date: Mon, 27 Jul 2020 15:02:58 -0500 Subject: [PATCH] =?UTF-8?q?Clean=20up=20the=20JSON=20code=20a=20bit=20(don?= =?UTF-8?q?=E2=80=99t=20need=20that=20extra=20filter)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eleventy.js | 8 -------- _data/metadata.json | 8 ++++---- feed/json.njk | 2 +- package.json | 3 ++- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 376f56c..d4774be 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -24,14 +24,6 @@ module.exports = function(eleventyConfig) { return DateTime.fromJSDate(dateObj, {zone: 'utc'}).toFormat('yyyy-LL-dd'); }); - // Content for jsonfeed - eleventyConfig.addFilter('jsonStringify', content => { - if (!content) { - content = ""; - } - return JSON.stringify(content); - }); - // Get the first `n` elements of a collection. eleventyConfig.addFilter("head", (array, n) => { if( n < 0 ) { diff --git a/_data/metadata.json b/_data/metadata.json index 7874f05..24113d7 100755 --- a/_data/metadata.json +++ b/_data/metadata.json @@ -1,20 +1,20 @@ { "title": "Your Blog Name", - "url": "https://myurl.com/", + "url": "https://example.com/", "description": "I am writing about my experiences as a naval navel-gazer.", "feed": { "subtitle": "I am writing about my experiences as a naval navel-gazer.", "filename": "feed.xml", "path": "/feed/feed.xml", - "id": "https://myurl.com/" + "id": "https://example.com/" }, "jsonfeed": { "path": "/feed/feed.json", - "url": "https://myurl.com/feed/feed.json" + "url": "https://example.com/feed/feed.json" }, "author": { "name": "Your Name Here", "email": "youremailaddress@example.com", - "url": "https://myurl.com/" + "url": "https://example.com/about-me/" } } diff --git a/feed/json.njk b/feed/json.njk index 38d823b..bee05e6 100644 --- a/feed/json.njk +++ b/feed/json.njk @@ -20,7 +20,7 @@ eleventyExcludeFromCollections: true "id": "{{ absolutePostUrl }}", "url": "{{ absolutePostUrl }}", "title": "{{ post.data.title }}", - "content_html": {{ post.templateContent | jsonStringify | safe }}, + "content_html": {% if post.templateContent %}{{ post.templateContent | dump | safe }}{% else %}""{% endif %}, "date_published": "{{ post.date | rssDate }}", "tags": [ {%- for c in post.data.category %} diff --git a/package.json b/package.json index 1e57551..bc37c4f 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "build": "eleventy", "watch": "eleventy --watch", "serve": "eleventy --serve", + "start": "eleventy --serve", "debug": "DEBUG=* eleventy" }, "repository": { @@ -25,7 +26,7 @@ "devDependencies": { "@11ty/eleventy": "^0.11.0", "@11ty/eleventy-navigation": "^0.1.6", - "@11ty/eleventy-plugin-rss": "^1.0.7", + "@11ty/eleventy-plugin-rss": "^1.0.9", "@11ty/eleventy-plugin-syntaxhighlight": "^3.0.1", "luxon": "^1.21.3", "markdown-it": "^8.4.2",