add rss feed

This commit is contained in:
Joshua Seigler 2025-05-16 23:32:43 -04:00
parent 5f954a80f5
commit 79b5e06aca
11 changed files with 1079 additions and 1086 deletions

55
assets/rss.xsl Normal file
View file

@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<html>
<head>
<style>
body {
font-family: "Inter",sans-serif;
font-size: 14px;
font-weight: 300;
color: hsl(217 17% 21%);
max-width: 1024px;
margin: 20px auto;
padding: 15px;
}
img {
float: right;
height: 40px;
margin: 12px 0;
}
a {
color: #4a66b9;
text-decoration: none;
}
</style>
</head>
<body>
<xsl:element name="img">
<xsl:attribute name="src">
<xsl:value-of select="//channel/image/url" />
</xsl:attribute>
</xsl:element>
<h1>
<xsl:value-of select="//channel/title" />
</h1>
<hr />
<xsl:apply-templates select="//item" />
</body>
</html>
</xsl:template>
<xsl:template match="item">
<content-item>
<h2>
<a href="{link}">
<xsl:value-of select="title" />
</a>
</h2>
<p>
<xsl:value-of select="description" />
</p>
</content-item>
</xsl:template>
</xsl:stylesheet>

75
assets/simple-atom.xslt Normal file
View file

@ -0,0 +1,75 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="3.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:atom="http://www.w3.org/2005/Atom">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="referrer" content="unsafe-url" />
<title><xsl:value-of select="/atom:feed/atom:title"/></title>
<link rel="stylesheet" href="https://www.rss.style/css/water.min.css" />
</head>
<body>
<h1>
<img alt="feed icon" src="https://www.vectorlogo.zone/logos/rss/rss-tile.svg" style="height:1em;vertical-align:middle;" />&#xa0;
<xsl:value-of select="/atom:feed/atom:title"/>
</h1>
<p>
<xsl:value-of select="/atom:feed/atom:subtitle"/>
</p>
<p>
This is the Atom&#xa0;<a href="https://www.rss.style/what-is-a-feed.html">news feed</a>&#xa0;for the&#xa0;
<a><xsl:attribute name="href">
<xsl:value-of select="/atom:feed/atom:link[@rel='alternate']/@href | /atom:feed/atom:link[not(@rel)]/@href"/>
</xsl:attribute>
<xsl:value-of select="/atom:feed/atom:title"/></a>&#xa0;
website.
</p>
<p>It is meant for&#xa0;<a href="https://www.rss.style/newsreaders.html">news readers</a>, not humans. Please copy-and-paste the URL into your news reader!</p>
<p>
<pre>
<code id="feedurl"><xsl:value-of select="/atom:feed/atom:link[@rel='self']/@href"/></code>
</pre>
<button
class="clipboard"
data-clipboard-target="#feedurl">
Copy to clipboard
</button>
</p>
<xsl:for-each select="/atom:feed/atom:entry">
<details><summary>
<a>
<xsl:attribute name="href">
<xsl:value-of select="atom:id"/>
</xsl:attribute>
<xsl:value-of select="atom:title"/>
</a>&#xa0;-&#xa0;
<xsl:value-of select="atom:updated" />
</summary>
<xsl:choose>
<xsl:when test="atom:content">
<xsl:value-of disable-output-escaping="yes" select="atom:content" />
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="atom:summary" />
</xsl:otherwise>
</xsl:choose>
</details>
</xsl:for-each>
<p><xsl:value-of select="count(/atom:feed/atom:entry)"/> news items.</p>
<p><small>Powered by <a href="https://www.rss.style/"><img referrerpolicy="origin" src="https://www.rss.style/favicon.svg" style="height:1em;padding-right:0.25em;vertical-align:middle;" />RSS.Style</a></small></p>
<script src="https://cdn.jsdelivr.net/npm/clipboard@2.0.11/dist/clipboard.min.js"></script>
<script>
new ClipboardJS('.clipboard');
</script>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View file

@ -1,17 +1,18 @@
const fs = require("fs");
const path = require("path");
const md = require("markdown-it");
const mdAnchor = require("markdown-it-anchor");
const mdFootnote = require("markdown-it-footnote");
const prettier = require("prettier");
const dayjs = require("dayjs");
const utc = require("dayjs/plugin/utc");
const clean = require("eleventy-plugin-clean");
const site = require("./site/_data/site");
import fs from "fs";
import path from "path";
import md from "markdown-it";
import mdAnchor from "markdown-it-anchor";
import mdFootnote from "markdown-it-footnote";
import prettier from "prettier";
import dayjs from "dayjs";
import utc from "dayjs/plugin/utc.js";
import clean from "eleventy-plugin-clean";
import site from "./site/_data/site.js";
import { feedPlugin } from "@11ty/eleventy-plugin-rss";
dayjs.extend(utc);
module.exports = (config) => {
export default (config) => {
const slugify = config.getFilter("slugify");
const url = config.getFilter("url");
const mdLib = md({
@ -88,6 +89,26 @@ module.exports = (config) => {
const buildTime = new Date().toISOString().replace(/[:.-]/g, "");
config.addGlobalData("buildTime", buildTime);
config.addPlugin(feedPlugin, {
type: "atom", // "atom", ""rss", or "json"
outputPath: "/feed.xml",
collection: {
name: "posts", // iterate over `collections.posts`
limit: 0, // 0 means no limit
},
metadata: {
language: "en",
title: site.title,
subtitle: site.description,
base: site.baseUrl,
author: {
name: "Joshua Seigler",
// email: "", // Optional
},
},
stylesheet: "/simple-atom.xslt",
});
return {
dir: {
input: "site",

1972
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,5 @@
{
"type": "module",
"name": "homepage-rewrite",
"version": "1.0.0",
"description": "",
@ -11,9 +12,11 @@
"author": "Joshua Seigler",
"license": "ISC",
"dependencies": {
"@11ty/eleventy": "^2.0.1",
"@11ty/eleventy": "^3.1.0",
"@11ty/eleventy-plugin-rss": "^2.0.4",
"@11ty/eleventy-upgrade-help": "^3.0.1",
"dayjs": "^1.11.11",
"eleventy-plugin-clean": "^1.2.6",
"eleventy-plugin-clean": "^2.0.1",
"markdown-it-anchor": "^9.0.1",
"markdown-it-footnote": "^4.0.0",
"prettier": "^3.3.1"

View file

@ -2,7 +2,7 @@ const isDev = process.env.ELEVENTY_ENV === "development";
const baseUrl = isDev ? "localhost:8080" : "https://joshua.seigler.net/";
module.exports = {
export default {
title: "joshua.seigler.net",
description: "Personal homepage of Joshua Seigler",
baseUrl,

View file

@ -1,3 +1,5 @@
<footer>
&copy; Joshua Seigler 2025. <a href="mailto:joshua@seigler.net?subject=Hello">Contact</a>
&copy; Joshua Seigler 2025. - <a href="mailto:joshua@seigler.net?subject=Hello">Contact</a>
-
<a href="/feed.xml">RSS</a>
</footer>

View file

@ -22,6 +22,7 @@ title: Joshua's Homepage
<meta name="twitter:image" content="{{ cover | absoluteURL }}" />
{% endif %}
<meta name="twitter:card" content="summary" />
<meta name="generator" content="{{ eleventy.generator }}">
</head>
<body data-font="english" data-path="{{page.url}}">
{% include "-header.njk" %}

View file

@ -1,4 +1,4 @@
module.exports = {
export default {
layout: "post.njk",
permalink: "/posts/{{ slug | default:title | slugify }}/",
tags: ["posts"],

View file

@ -1,4 +1,4 @@
module.exports = {
export default {
layout: "base.njk",
tags: ["recipes"],
};

View file

@ -1,4 +1,4 @@
module.exports = {
export default {
tags: ["timeline"],
permalink: false,
};