diff --git a/.eleventy.js b/.eleventy.js
index 2c787f5d..a09f7569 100644
--- a/.eleventy.js
+++ b/.eleventy.js
@@ -89,6 +89,7 @@ module.exports = function (eleventyConfig) {
// markdown filter
eleventyConfig.addLiquidFilter('markdown', (content) => {
+ if (!content) return
return md.render(content)
})
diff --git a/config/filters.js b/config/filters.js
index 64d86b34..52465553 100644
--- a/config/filters.js
+++ b/config/filters.js
@@ -14,13 +14,40 @@ module.exports = {
},
dashLower: (string) => string.replace(/\s+/g, '-').toLowerCase(),
encodeAmp: (string) => {
+ if (!string) return
const pattern = /&(?!(?:[a-zA-Z]+|#[0-9]+|#x[0-9a-fA-F]+);)/g
const replacement = '&'
return string.replace(pattern, replacement)
},
stripUtm: (string) => {
+ if (!string) return
return string.replace(utmPattern, '')
},
+ normalizeEntries: (entries) => {
+ return entries.map((entry) => {
+ let excerpt = ''
+ let date = ''
+
+ // set the entry excerpt
+ if (entry.data?.post_excerpt) excerpt = entry.data.post_excerpt
+ if (entry.description) excerpt = entry.description
+
+ // set the entry date
+ if (entry.date) date = entry.date
+ if (entry.dateAdded) date = entry.dateAdded
+ if (entry.date_published) date = entry.date_published
+
+ // if there's a valid entry return a normalized object
+ if (entry) {
+ return {
+ title: entry.data?.title || entry.title,
+ url: entry.url.includes('http') ? entry.url : `https://coryd.dev${entry.url}`,
+ date,
+ excerpt,
+ }
+ }
+ })
+ },
getPostImage: (image) => {
if (image && image !== '') return image
return 'https://coryd.dev/assets/img/social-card.jpg'
diff --git a/src/_includes/feeds/books.liquid b/src/_includes/feeds/books.liquid
deleted file mode 100644
index aac95a64..00000000
--- a/src/_includes/feeds/books.liquid
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- {% block title %}Books • Cory Dransfeldt{% endblock %}
-
-
-
-
- {% block update %}{{ books[0].dateAdded | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
- {{ site.url }}
-
- {{ site.name }}
- {{ site.email }}
-
- {{ eleventy.generator }}
- {% block entries %}{% endblock %}
-
\ No newline at end of file
diff --git a/src/_includes/feeds/feed.liquid b/src/_includes/feeds/feed.liquid
deleted file mode 100644
index 2498db54..00000000
--- a/src/_includes/feeds/feed.liquid
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- {% block title %}All posts • Cory Dransfeldt{% endblock %}
-
-
-
-
- {% block update %}{{ collections.posts[0].date | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
- {{ site.url }}/
-
- {{ site.name }}
- {{ site.email }}
-
- {{ eleventy.generator }}
- {% block entries %}{% endblock %}
-
diff --git a/src/_includes/feeds/follow.liquid b/src/_includes/feeds/follow.liquid
deleted file mode 100644
index 682bc4ac..00000000
--- a/src/_includes/feeds/follow.liquid
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- {% block title %}Follow • Cory Dransfeldt{% endblock %}
-
-
-
-
- {% block update %}{{ follow.posts[0].date_published | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
- {{ site.url }}
-
- {{ site.name }}
- {{ site.email }}
-
- {{ eleventy.generator }}
- {% block entries %}{% endblock %}
-
\ No newline at end of file
diff --git a/src/_includes/feeds/links.liquid b/src/_includes/feeds/links.liquid
deleted file mode 100644
index 831c6451..00000000
--- a/src/_includes/feeds/links.liquid
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- {% block title %}Links • Cory Dransfeldt{% endblock %}
-
-
-
-
- {% block update %}{{ links[0].date | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
- {{ site.url }}
-
- {{ site.name }}
- {{ site.email }}
-
- {{ eleventy.generator }}
- {% block entries %}{% endblock %}
-
\ No newline at end of file
diff --git a/src/_includes/main.liquid b/src/_includes/main.liquid
index f5d2c8be..90ab8afd 100644
--- a/src/_includes/main.liquid
+++ b/src/_includes/main.liquid
@@ -1,7 +1,6 @@
---
layout: base
---
-
{{ content }}
diff --git a/src/_includes/partials/feeds/content.liquid b/src/_includes/partials/feeds/content.liquid
new file mode 100644
index 00000000..fd53660d
--- /dev/null
+++ b/src/_includes/partials/feeds/content.liquid
@@ -0,0 +1,26 @@
+
+
+
+ {% assign entries = data | normalizeEntries %}
+ {{ title }}
+
+
+
+ {{ updated | date: "%Y-%m-%dT%H:%M:%S-08:00" }}
+ {{ site.url }}
+
+ {{ site.name }}
+ {{ site.email }}
+
+ {{ eleventy.generator }}
+ {% for entry in entries limit: 20 -%}
+
+ {{ entry.title | escape }}
+
+ {{ entry.date | date: "%m.%d.%Y" }}
+ {{ entry.url | stripUtm | encodeAmp }}
+
+
+
+ {%- endfor %}
+
\ No newline at end of file
diff --git a/src/_includes/feed.liquid b/src/_includes/partials/feeds/layout.liquid
similarity index 100%
rename from src/_includes/feed.liquid
rename to src/_includes/partials/feeds/layout.liquid
diff --git a/src/assets/feed.md b/src/assets/feed.md
index 0d8e06b5..705da092 100644
--- a/src/assets/feed.md
+++ b/src/assets/feed.md
@@ -1,4 +1,4 @@
---
-layout: feed
+layout: partials/feeds/layout
permalink: /assets/feeds/template.xsl
---
\ No newline at end of file
diff --git a/src/feeds/books.liquid b/src/feeds/books.liquid
deleted file mode 100644
index de2a8a68..00000000
--- a/src/feeds/books.liquid
+++ /dev/null
@@ -1,19 +0,0 @@
----
-layout: null
-permalink: /feeds/books
----
-{% layout "./_includes/feeds/books.liquid" %}
-{% block title %}Books • Cory Dransfeldt{% endblock %}
-{% block self %}books.xml{% endblock %}
-{% block update %}{{ books[0].dateAdded | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
-{% block entries %}
-{% for book in books %}
-
- {{ book.title | escape }}
-
- {{ book.dateAdded | date: "%m.%d.%Y" }}
- {{ book.url | stripUtm | encodeAmp }}
-
-
-{% endfor %}
-{% endblock %}
\ No newline at end of file
diff --git a/src/feeds/books.md b/src/feeds/books.md
new file mode 100644
index 00000000..80d3923d
--- /dev/null
+++ b/src/feeds/books.md
@@ -0,0 +1,12 @@
+---
+layout: null
+permalink: /feeds/books
+---
+{% render "partials/feeds/content.liquid"
+ permalink:'/feeds/books'
+ title:'Books • Cory Dransfeldt'
+ data:books
+ updated:books[0].dateAdded
+ site:site
+ eleventy:eleventy
+%}
\ No newline at end of file
diff --git a/src/feeds/feed.liquid b/src/feeds/feed.liquid
deleted file mode 100644
index c6c65710..00000000
--- a/src/feeds/feed.liquid
+++ /dev/null
@@ -1,23 +0,0 @@
----
-layout: null
-permalink: /feeds/posts
----
-{% layout "./_includes/feeds/feed.liquid" %}
-{% block title %}All posts • Cory Dransfeldt{% endblock %}
-{% block self %}feed.xml{% endblock %}
-{% block update %}
- {{ collections.posts[0].date | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
-{% block entries %}
- {% assign posts = collections.posts | reverse %}
- {% for post in posts limit: 15 %}
-
- {{ post.data.title }}
-
- {{ post.date | date: "%m.%d.%Y" }}
- {{ site.url }}{{ post.url }}
-
- {{ post.data.post_excerpt | markdown | escape }}
-
-
- {% endfor %}
-{% endblock %}
\ No newline at end of file
diff --git a/src/feeds/feed.md b/src/feeds/feed.md
new file mode 100644
index 00000000..43a418ce
--- /dev/null
+++ b/src/feeds/feed.md
@@ -0,0 +1,13 @@
+---
+layout: null
+permalink: /feeds/posts
+---
+{% assign posts = collections.posts | reverse %}
+{% render "partials/feeds/content.liquid"
+ permalink:'/feeds/posts'
+ title:'All posts • Cory Dransfeldt'
+ data:posts
+ updated:posts[0].date
+ site:site
+ eleventy:eleventy
+%}
\ No newline at end of file
diff --git a/src/feeds/follow.liquid b/src/feeds/follow.liquid
deleted file mode 100644
index f0e6efd0..00000000
--- a/src/feeds/follow.liquid
+++ /dev/null
@@ -1,19 +0,0 @@
----
-layout: null
-permalink: /feeds/follow
----
-{% layout "./_includes/feeds/follow.liquid" %}
-{% block title %}Follow • Cory Dransfeldt{% endblock %}
-{% block self %}follow.xml{% endblock %}
-{% block update %}{{ follow.posts[0].date_published | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
-{% block entries %}
-{% for item in follow.posts %}
-
- {{ item.title | escape }}
-
- {{ item.date_published | date: "%m.%d.%Y" }}
- {{ item.url | stripUtm | encodeAmp }}
-
-
-{% endfor %}
-{% endblock %}
\ No newline at end of file
diff --git a/src/feeds/follow.md b/src/feeds/follow.md
new file mode 100644
index 00000000..1b2fd6a9
--- /dev/null
+++ b/src/feeds/follow.md
@@ -0,0 +1,12 @@
+---
+layout: null
+permalink: /feeds/follow
+---
+{% render "partials/feeds/content.liquid"
+ permalink:'/feeds/follow'
+ title:'Follow • Cory Dransfeldt'
+ data:follow.posts
+ updated:follow.posts[0].date_published
+ site:site
+ eleventy:eleventy
+%}
\ No newline at end of file
diff --git a/src/feeds/links.liquid b/src/feeds/links.liquid
deleted file mode 100644
index ffdc554d..00000000
--- a/src/feeds/links.liquid
+++ /dev/null
@@ -1,19 +0,0 @@
----
-layout: null
-permalink: /feeds/links
----
-{% layout "./_includes/feeds/links.liquid" %}
-{% block title %}Links • Cory Dransfeldt{% endblock %}
-{% block self %}links.xml{% endblock %}
-{% block update %}{{ links[0].date | date: "%Y-%m-%dT%H:%M:%S-08:00" }}{% endblock %}
-{% block entries %}
-{% for link in links %}
-
- {{ link.title | escape }}
-
- {{ link.date | date: "%m.%d.%Y" }}
- {{ link.url | stripUtm | encodeAmp }}
-
-
-{% endfor %}
-{% endblock %}
\ No newline at end of file
diff --git a/src/feeds/links.md b/src/feeds/links.md
new file mode 100644
index 00000000..d3d98a24
--- /dev/null
+++ b/src/feeds/links.md
@@ -0,0 +1,12 @@
+---
+layout: null
+permalink: /feeds/links
+---
+{% render "partials/feeds/content.liquid"
+ permalink:'/feeds/links'
+ title:'Links • Cory Dransfeldt'
+ data:links
+ updated:links[0].date
+ site:site
+ eleventy:eleventy
+%}
\ No newline at end of file