summary refs log tree commit diff
diff options
context:
space:
mode:
authorStarfall <us@starfall.systems>2023-05-23 12:14:00 -0500
committerStarfall <us@starfall.systems>2023-05-24 12:51:23 -0500
commit5c0a183a1d830479e4cfc705bdc9f13b2b1efac2 (patch)
tree40dc719987731076bcdc80632aefa4e74b1817d5
parent1df389da097411e437aa33aa104132bc593e1ed4 (diff)
feature: atom feed
- add atom feed
- add theme-colored feed icon to /blog/
-rw-r--r--_includes/base.njk17
-rw-r--r--eleventy.config.js3
-rwxr-xr-ximg/feed-icon.svg17
-rw-r--r--package-lock.json27
-rw-r--r--package.json1
-rw-r--r--src/blog.njk14
-rw-r--r--src/feed.njk38
7 files changed, 112 insertions, 5 deletions
diff --git a/_includes/base.njk b/_includes/base.njk
index 6ff7553..a11c22c 100644
--- a/_includes/base.njk
+++ b/_includes/base.njk
@@ -3,11 +3,16 @@ title = "Starfall"
 ---
 <!doctype html>
 <html lang=en-US dir=ltr>
-<title>{{ title }}</title>
-<meta charset=UTF-8>
-<meta name=robots content="noindex, nofollow">
-<meta name=viewport content="width=device-width, initial-scale=1">
-<link rel=stylesheet href=/css/terminal.css>
+<head>
+	<title>{{ title }}</title>
+	<meta charset=UTF-8>
+	<meta name=robots content="noindex, nofollow">
+	<meta name=viewport content="width=device-width, initial-scale=1">
+	<link rel=stylesheet href=/css/terminal.css>
+	{{ extraHeadContent | safe }}
+</head>
+
+<body>
 <!-- todo color picker -->
 
 <header>
@@ -30,3 +35,5 @@ title = "Starfall"
 </section>
 <div style=text-align:center>⋁/⋀</div>
 </footer>
+
+</body>
diff --git a/eleventy.config.js b/eleventy.config.js
index 36722b2..a33d908 100644
--- a/eleventy.config.js
+++ b/eleventy.config.js
@@ -1,5 +1,6 @@
 const toml = require('@iarna/toml')
 const eleventyNavigation = require('@11ty/eleventy-navigation')
+const eleventyRss = require('@11ty/eleventy-plugin-rss')
 
 filter_local_date = function(date) {
 	// yyyy-MM-dd
@@ -17,8 +18,10 @@ filter_rfc3339_datetime = function(date) {
 
 module.exports = function(eleventyConfig) {
 	eleventyConfig.addPlugin(eleventyNavigation)
+	eleventyConfig.addPlugin(eleventyRss)
 
 	eleventyConfig.addPassthroughCopy('./css/')
+	eleventyConfig.addPassthroughCopy('./img/')
 
 	eleventyConfig.addFilter('local_date', filter_local_date)
 	eleventyConfig.addFilter('rfc3339_datetime', filter_rfc3339_datetime)
diff --git a/img/feed-icon.svg b/img/feed-icon.svg
new file mode 100755
index 0000000..0585d8a
--- /dev/null
+++ b/img/feed-icon.svg
@@ -0,0 +1,17 @@
+<?xml version="1.0"?>

+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> 

+<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="128px" height="128px" id="RSSicon" viewBox="0 0 256 256">

+<defs>

+<linearGradient x1="0.085" y1="0.085" x2="0.915" y2="0.915" id="RSSg">

+<stop  offset="0.0" stop-color="#808080"/><stop  offset="0.2785" stop-color="#929292"/>

+<stop  offset="0.5" stop-color="#9B9B9B"/><stop  offset="0.5871" stop-color="#919191"/>

+<stop  offset="0.8427" stop-color="#797979"/><stop  offset="1.0" stop-color="#707070"/>

+</linearGradient>

+</defs>

+<rect width="256" height="256" rx="55" ry="55" x="0"  y="0"  fill="#777777"/>

+<rect width="246" height="246" rx="50" ry="50" x="5"  y="5"  fill="#999999"/>

+<rect width="236" height="236" rx="47" ry="47" x="10" y="10" fill="url(#RSSg)"/>

+<circle cx="68" cy="189" r="24" fill="#FFF"/>

+<path d="M160 213h-34a82 82 0 0 0 -82 -82v-34a116 116 0 0 1 116 116z" fill="#FFF"/>

+<path d="M184 213A140 140 0 0 0 44 73 V 38a175 175 0 0 1 175 175z" fill="#FFF"/>

+</svg>

diff --git a/package-lock.json b/package-lock.json
index 32621d8..15f332c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -10,6 +10,7 @@
 			"devDependencies": {
 				"@11ty/eleventy": "^2.0.1",
 				"@11ty/eleventy-navigation": "^0.3.5",
+				"@11ty/eleventy-plugin-rss": "^1.2.0",
 				"@iarna/toml": "^3.0.0"
 			}
 		},
@@ -117,6 +118,21 @@
 				"url": "https://opencollective.com/11ty"
 			}
 		},
+		"node_modules/@11ty/eleventy-plugin-rss": {
+			"version": "1.2.0",
+			"resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.2.0.tgz",
+			"integrity": "sha512-YzFnSH/5pObcFnqZ2sAQ782WmpOZHj1+xB9ydY/0j7BZ2jUNahn53VmwCB/sBRwXA/Fbwwj90q1MLo01Ru0UaQ==",
+			"dev": true,
+			"dependencies": {
+				"debug": "^4.3.4",
+				"posthtml": "^0.16.6",
+				"posthtml-urls": "1.0.0"
+			},
+			"funding": {
+				"type": "opencollective",
+				"url": "https://opencollective.com/11ty"
+			}
+		},
 		"node_modules/@11ty/eleventy-utils": {
 			"version": "1.0.1",
 			"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.1.tgz",
@@ -2453,6 +2469,17 @@
 				"dependency-graph": "^0.11.0"
 			}
 		},
+		"@11ty/eleventy-plugin-rss": {
+			"version": "1.2.0",
+			"resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-1.2.0.tgz",
+			"integrity": "sha512-YzFnSH/5pObcFnqZ2sAQ782WmpOZHj1+xB9ydY/0j7BZ2jUNahn53VmwCB/sBRwXA/Fbwwj90q1MLo01Ru0UaQ==",
+			"dev": true,
+			"requires": {
+				"debug": "^4.3.4",
+				"posthtml": "^0.16.6",
+				"posthtml-urls": "1.0.0"
+			}
+		},
 		"@11ty/eleventy-utils": {
 			"version": "1.0.1",
 			"resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-1.0.1.tgz",
diff --git a/package.json b/package.json
index efdc36e..e680afa 100644
--- a/package.json
+++ b/package.json
@@ -11,6 +11,7 @@
 	"devDependencies": {
 		"@11ty/eleventy": "^2.0.1",
 		"@11ty/eleventy-navigation": "^0.3.5",
+		"@11ty/eleventy-plugin-rss": "^1.2.0",
 		"@iarna/toml": "^3.0.0"
 	}
 }
diff --git a/src/blog.njk b/src/blog.njk
index 4d8dfab..87cf12a 100644
--- a/src/blog.njk
+++ b/src/blog.njk
@@ -1,5 +1,6 @@
 ---
 layout = "base.njk"
+extraHeadContent = "<link rel=alternate type=application/atom+xml title=Atom href=feed.xml>"
 
 [pagination]
 data = "collections.post"
@@ -11,6 +12,18 @@ reverse = true
 key = "Blog"
 order = 1
 ---
+<style>
+.feed-icon {
+	display: block;
+	float: right;
+	height: 1em;
+	width: 1em;
+	background: url('/img/feed-icon.svg') center/contain, var(--fg);
+	background-blend-mode: luminosity;
+	mask: url('/img/feed-icon.svg') 0 0/100% 100%;
+}
+</style>
+<a href=feed.xml alt="Atom feed" class=feed-icon></a>
 {% for post in posts %}
 <article class=blogpost>
 	<h2><a href="{{ post.url | url }}">{{ post.data.title }}</a></h2>
@@ -22,3 +35,4 @@ order = 1
 	{%- endif -%}
 </article>
 {% endfor %}
+
diff --git a/src/feed.njk b/src/feed.njk
new file mode 100644
index 0000000..d1a9c0a
--- /dev/null
+++ b/src/feed.njk
@@ -0,0 +1,38 @@
+---
+permalink = "feed.xml"
+
+[metadata]
+name = "devin & Alex Starfall"
+email = "us@starfall.systems"
+baseurl = "https://starfall.systems/"
+blogurl = "https://starfall.systems/blog/"
+---
+<?xml version="1.0" encoding="utf-8"?>
+<feed xmlns="http://www.w3.org/2005/Atom">
+	<title>Starfall's Blog</title>
+	<link href="{{ permalink | absoluteUrl(metadata.baseurl) }}" rel="self"/>
+	<link href="{{ metadata.blogurl }}"/>
+	<updated>{{ collections.post | getNewestCollectionItemDate | dateToRfc3339 }}</updated>
+	<id>{{ metadata.baseurl }}</id>
+
+	<author>
+		<name>{{ metadata.name }}</name>
+		<email>{{ metadata.email }}</email>
+	</author>
+
+{% for post in collections.post | reverse %}
+{%- set absolutePostUrl = post.url | absoluteUrl(metadata.baseurl) %}
+	<entry>
+		<title>{{ post.data.title }}</title>
+		<updated>{{ post.date | dateToRfc3339 }}</updated>
+		<link href="{{ absolutePostUrl }}"/>
+		<id>{{ absolutePostUrl }}</id>
+		{%- if post.data.page.excerpt %}
+		<summary>{{- post.data.page.excerpt -}}</summary>
+		{% endif -%}
+		<content type="html">
+			{{- post.templateContent | htmlToAbsoluteUrls(absolutePostUrl) -}}
+		</content>
+	</entry>
+{% endfor %}
+</feed>