From ba690649c025764959ba480e4e0c2de22542eeaa Mon Sep 17 00:00:00 2001 From: Ava Gaiety W Date: Tue, 8 Jul 2025 22:26:17 -0600 Subject: [PATCH] rss feed, fix blog header link --- .eleventy.js | 25 +++++++++++++++++++++++-- _includes/content.njk | 13 ++++++++++++- blog/index.md | 2 +- package-lock.json | 32 ++++++++++++++++++++++++++++++++ package.json | 1 + 5 files changed, 69 insertions(+), 4 deletions(-) diff --git a/.eleventy.js b/.eleventy.js index 5de35b3..706dd30 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -10,6 +10,7 @@ const markdownitClass = require('@toycode/markdown-it-class'); const markdownitImageFigures = require('markdown-it-image-figures'); const anchor = require('markdown-it-anchor'); const cheerio = require('cheerio'); +const { feedPlugin } = require("@11ty/eleventy-plugin-rss"); const expectedInputFormat = 'YYYY-MM-DD'; const defaultOuputFormat = 'LL'; @@ -48,7 +49,7 @@ const md = markdownit({ linkify: true, html: true, typographer: true, - highlight: function (str, lang) { + highlight: function(str, lang) { if (lang && hljs.getLanguage(lang)) { try { return hljs.highlight(str, { language: lang }).value + `${lang}`; @@ -66,11 +67,31 @@ md.use(anchor, { permalink: anchor.permalink.headerLink() }) -module.exports = function (eleventyConfig) { +module.exports = function(eleventyConfig) { let nunjucksEnvironment = new Nunjucks.Environment( new Nunjucks.FileSystemLoader("_includes") ); + eleventyConfig.addPlugin(feedPlugin, { + type: "rss", + outputPath: "/blog/rss", + collection: { + name: "posts", + limit: 0, + }, + metadata: { + language: 'en', + title: 'Gaiet\'s Blog', + subtitle: 'Various writings on code, design, art and life.', + base: 'https://gaiety.me/blog', + author: { + name: 'Ava Gaiety W.', + email: 'ava+blog@wroten.me', + } + } + }) + eleventyConfig.configureErrorReporting({ allowMissingExtensions: true }) + eleventyConfig.setLibrary('md', md); eleventyConfig.addPassthroughCopy('assets'); diff --git a/_includes/content.njk b/_includes/content.njk index 5c452fb..5de3a21 100644 --- a/_includes/content.njk +++ b/_includes/content.njk @@ -6,7 +6,12 @@

{{ title }} - in {{ tags[0] | capitalize }} + in + {% if '/blog' in page.url %} + Blog + {% else %} + {{ tags[0] | capitalize }} + {% endif %}

@@ -18,6 +23,12 @@
{{ content | safe }}
+ {% if '/blog' in page.url %} +
+ + {% endif %} diff --git a/blog/index.md b/blog/index.md index a927f76..7a1c185 100644 --- a/blog/index.md +++ b/blog/index.md @@ -1,7 +1,7 @@ --- layout: blog-list.njk description: - Various writings on code, design, art and life. + Various writings on code, design, art and life. [RSS](/blog/rss) eleventyExcludeFromCollections: true --- diff --git a/package-lock.json b/package-lock.json index 9a7fcfe..9faaaaf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,6 +10,7 @@ "license": "ISC", "devDependencies": { "@11ty/eleventy": "^3.0.0", + "@11ty/eleventy-plugin-rss": "^2.0.4", "@11ty/eleventy-plugin-syntaxhighlight": "^3.1.3", "@catppuccin/highlightjs": "^1.0.1", "@catppuccin/tailwindcss": "^0.1.6", @@ -185,6 +186,37 @@ "url": "https://opencollective.com/11ty" } }, + "node_modules/@11ty/eleventy-plugin-rss": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-rss/-/eleventy-plugin-rss-2.0.4.tgz", + "integrity": "sha512-LF60sGVlxGTryQe3hTifuzrwF8R7XbrNsM2xfcDcNMSliLN4kmB+7zvoLRySRx0AQDjqhPTAeeeT0ra6/9zHUQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@11ty/eleventy-utils": "^2.0.0", + "@11ty/posthtml-urls": "^1.0.1", + "debug": "^4.4.0", + "posthtml": "^0.16.6" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } + }, + "node_modules/@11ty/eleventy-plugin-rss/node_modules/@11ty/eleventy-utils": { + "version": "2.0.7", + "resolved": "https://registry.npmjs.org/@11ty/eleventy-utils/-/eleventy-utils-2.0.7.tgz", + "integrity": "sha512-6QE+duqSQ0GY9rENXYb4iPR4AYGdrFpqnmi59tFp9VrleOl0QSh8VlBr2yd6dlhkdtj7904poZW5PvGr9cMiJQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/11ty" + } + }, "node_modules/@11ty/eleventy-plugin-syntaxhighlight": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/@11ty/eleventy-plugin-syntaxhighlight/-/eleventy-plugin-syntaxhighlight-3.2.2.tgz", diff --git a/package.json b/package.json index f4256b7..adfce71 100644 --- a/package.json +++ b/package.json @@ -30,6 +30,7 @@ }, "devDependencies": { "@11ty/eleventy": "^3.0.0", + "@11ty/eleventy-plugin-rss": "^2.0.4", "@11ty/eleventy-plugin-syntaxhighlight": "^3.1.3", "@catppuccin/highlightjs": "^1.0.1", "@catppuccin/tailwindcss": "^0.1.6",