diff --git a/build_garden.js b/build_garden.js index 4c34cfd4..d9b7106b 100644 --- a/build_garden.js +++ b/build_garden.js @@ -3,6 +3,7 @@ const path = require("path"); const util = require('node:util'); const exec = util.promisify(require('node:child_process').exec); +const { Feed } = require('feed'); function walk(dir, cb) { const list = fs.readdirSync(dir); @@ -194,6 +195,29 @@ function toSlug(string) { // Build changelog fs.mkdirSync("./site/changelog"); + const feed = new Feed({ + title: "The Paper Pilot's Digital Garden Changelog", + description: "A feed of updates made to my digital garden!", + id: "https://www.thepaperpilot.org/changelog/", + link: "https://www.thepaperpilot.org/changelog/", + language: "en", // optional, used only in RSS 2.0, possible values: http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes + // image: "http://example.com/image.png", + // favicon: "http://example.com/favicon.ico", + copyright: `All rights reserved ${new Date().getFullYear()}, The Paper Pilot`, + // updated: new Date(2013, 6, 14), // optional, default = today + // generator: "awesome", // optional, default = 'Feed for Node.js' + feedLinks: { + rss: "https://www.thepaperpilot.org/changelog/rss", + json: "https://www.thepaperpilot.org/changelog/json", + atom: "https://www.thepaperpilot.org/changelog/atom" + }, + author: { + name: "The Paper Pilot", + email: "thepaperpilot@incremental.social", + link: "https://www.thepaperpilot.org/" + } + }); + const { stdout } = await exec('git log --after="2024-06-03T0:0:0+0000" --pretty=%H origin/master -- site/garden'); const entries = await Promise.all(stdout.split("\n").filter(p => p).map(hash => new Promise(async (resolve) => { const { stdout: time } = await exec(`git show --quiet --format=%as ${hash}`); @@ -213,11 +237,33 @@ function toSlug(string) { return `${page}${changes}`; }).join("\n"); + const commitLink = `https://code.incremental.social/thepaperpilot/pages/commit/${hash}` + const content = ` + + + + + + + +${changes} + +
PageChanges
`; + + feed.addItem({ + title: summary, + id: commitLink, + link: commitLink, + description: summary, + content, + date: new Date(time) + }); + resolve( `

${summary}

-Pushed on +Pushed on @@ -232,7 +278,8 @@ ${changes}

`); }))); - const fd = fs.openSync("site/changelog/index.md", "w+"); + + let fd = fs.openSync("site/changelog/index.md", "w+"); fs.writeSync(fd, `--- title: Changelog @@ -248,7 +295,18 @@ next: false ${entries.join("\n\n")} -` -); +`); + fs.closeSync(fd); + + fd = fs.openSync("site/public/garden/rss", "w+"); + fs.writeSync(fd, feed.rss2()); + fs.closeSync(fd); + + fd = fs.openSync("site/public/garden/atom", "w+"); + fs.writeSync(fd, feed.atom1()); + fs.closeSync(fd); + + fd = fs.openSync("site/public/garden/json", "w+"); + fs.writeSync(fd, feed.json1()); fs.closeSync(fd); })(); diff --git a/package.json b/package.json index 804e19dd..7779b190 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ "license": "ISC", "homepage": "https://www.thepaperpilot.org/thepaperpilot.github.io", "dependencies": { + "feed": "^4.2.2", "flexsearch": "^0.7.43", "run-script-os": "^1.1.6", "vitepress": "^1.2.2", diff --git a/yarn.lock b/yarn.lock index a275e52e..7839bb77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -749,6 +749,13 @@ estree-walker@^2.0.2: resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz" integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w== +feed@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/feed/-/feed-4.2.2.tgz#865783ef6ed12579e2c44bbef3c9113bc4956a7e" + integrity sha512-u5/sxGfiMfZNtJ3OvQpXcvotFpYkL0n9u9mM2vkui2nGo8b4wvDkJ8gAkYqbA8QpGyFCv3RK0Z+Iv+9veCS9bQ== + dependencies: + xml-js "^1.6.11" + flexsearch@^0.7.43: version "0.7.43" resolved "https://registry.yarnpkg.com/flexsearch/-/flexsearch-0.7.43.tgz#34f89b36278a466ce379c5bf6fb341965ed3f16c" @@ -1107,3 +1114,10 @@ vue@^3.4.27: "@vue/runtime-dom" "3.4.27" "@vue/server-renderer" "3.4.27" "@vue/shared" "3.4.27" + +xml-js@^1.6.11: + version "1.6.11" + resolved "https://registry.yarnpkg.com/xml-js/-/xml-js-1.6.11.tgz#927d2f6947f7f1c19a316dd8eea3614e8b18f8e9" + integrity sha512-7rVi2KMfwfWFl+GpPg6m80IVMWXLRjO+PxTq7V2CDhoGak0wzYzFgUY2m4XJ47OGdXd8eLE8EmwfAmdjw7lC1g== + dependencies: + sax "^1.2.4"