From e557b56eb71dca8d93958c18d599ede6d98dc1c9 Mon Sep 17 00:00:00 2001 From: alifeee Date: Thu, 20 Jun 2024 23:48:23 +0100 Subject: [PATCH] add rss feed --- .eleventy.js | 29 +++++++++++++++++++++++++++++ rss.hbs | 20 ++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 rss.hbs diff --git a/.eleventy.js b/.eleventy.js index 5e4fe0d..171a6c4 100644 --- a/.eleventy.js +++ b/.eleventy.js @@ -1,6 +1,35 @@ +const fs = require("fs"); + +// generate hash of a string +String.prototype.hashCode = function () { + var hash = 0, + i, + chr; + if (this.length === 0) return hash; + for (i = 0; i < this.length; i++) { + chr = this.charCodeAt(i); + hash = (hash << 5) - hash + chr; + hash |= 0; // Convert to 32bit integer + } + return hash; +}; + module.exports = function (eleventyConfig) { // static files eleventyConfig.addPassthroughCopy({ public: "/" }); eleventyConfig.addPassthroughCopy({ springy: "/" }); eleventyConfig.addPassthroughCopy("polycule.json"); + + eleventyConfig.addFilter("fullisodate", (dt) => { + return dt.toISOString(); + }); + eleventyConfig.addFilter("now", () => { + return new Date(); + }); + eleventyConfig.addFilter("polycule", () => { + return fs.readFileSync("polycule.json").toString(); + }); + eleventyConfig.addFilter("id", (toid) => { + return toid.hashCode(); + }); }; diff --git a/rss.hbs b/rss.hbs new file mode 100644 index 0000000..43a8c0e --- /dev/null +++ b/rss.hbs @@ -0,0 +1,20 @@ +--- +permalink: index.xml +--- + + + polycule + + {{fullisodate (now)}} + + alifeee + + {{URIs.root}}/ + + polycule + + uuid:{{id (polycule)}} + {{fullisodate (now)}} + updated! + + \ No newline at end of file