Skip to content

Commit

Permalink
add rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
alifeee committed Jun 20, 2024
1 parent db47c01 commit e557b56
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .eleventy.js
Original file line number Diff line number Diff line change
@@ -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();
});
};
20 changes: 20 additions & 0 deletions rss.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
---
permalink: index.xml
---
<?xml version='1.0' encoding='UTF-8'?>
<feed xmlns="http://www.w3.org/2005/Atom">
<title>polycule</title>
<link href='{{log URIs.root}}/polycule/index.xml' rel='self' />
<updated>{{fullisodate (now)}}</updated>
<author>
<name>alifeee</name>
</author>
<id>{{URIs.root}}/</id>
<entry>
<title>polycule</title>
<link href='{{URIs.root}}/polycule/' />
<id>uuid:{{id (polycule)}}</id>
<updated>{{fullisodate (now)}}</updated>
<summary>updated!</summary>
</entry>
</feed>

0 comments on commit e557b56

Please sign in to comment.