Add rss, atom, and json feeds for changelog
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 56s
All checks were successful
Build and Deploy / build-and-deploy (push) Successful in 56s
This commit is contained in:
parent
200996e77f
commit
4ee032fd84
3 changed files with 77 additions and 4 deletions
|
@ -3,6 +3,7 @@ const path = require("path");
|
||||||
|
|
||||||
const util = require('node:util');
|
const util = require('node:util');
|
||||||
const exec = util.promisify(require('node:child_process').exec);
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
const { Feed } = require('feed');
|
||||||
|
|
||||||
function walk(dir, cb) {
|
function walk(dir, cb) {
|
||||||
const list = fs.readdirSync(dir);
|
const list = fs.readdirSync(dir);
|
||||||
|
@ -194,6 +195,29 @@ function toSlug(string) {
|
||||||
// Build changelog
|
// Build changelog
|
||||||
fs.mkdirSync("./site/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 { 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 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}`);
|
const { stdout: time } = await exec(`git show --quiet --format=%as ${hash}`);
|
||||||
|
@ -213,11 +237,33 @@ function toSlug(string) {
|
||||||
return `<tr><td><a href="/garden/${page}">${page}</a></td><td style="font-family: monospace; white-space: nowrap;">${changes}</td></tr>`;
|
return `<tr><td><a href="/garden/${page}">${page}</a></td><td style="font-family: monospace; white-space: nowrap;">${changes}</td></tr>`;
|
||||||
}).join("\n");
|
}).join("\n");
|
||||||
|
|
||||||
|
const commitLink = `https://code.incremental.social/thepaperpilot/pages/commit/${hash}`
|
||||||
|
const content = `<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="align: center">Page</th>
|
||||||
|
<th style="align: center">Changes</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${changes}
|
||||||
|
</tbody>
|
||||||
|
</table>`;
|
||||||
|
|
||||||
|
feed.addItem({
|
||||||
|
title: summary,
|
||||||
|
id: commitLink,
|
||||||
|
link: commitLink,
|
||||||
|
description: summary,
|
||||||
|
content,
|
||||||
|
date: new Date(time)
|
||||||
|
});
|
||||||
|
|
||||||
resolve(
|
resolve(
|
||||||
`<article class="h-entry">
|
`<article class="h-entry">
|
||||||
<h2 class="p-name">${summary}</h2>
|
<h2 class="p-name">${summary}</h2>
|
||||||
<p class="e-content">
|
<p class="e-content">
|
||||||
<a class="u-url" href="https://code.incremental.social/thepaperpilot/pages/commit/${hash}">Pushed on <time class="dt-published">${time}</time></a>
|
<a class="u-url" href="${commitLink}">Pushed on <time class="dt-published">${time}</time></a>
|
||||||
<table>
|
<table>
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -232,7 +278,8 @@ ${changes}
|
||||||
</p>
|
</p>
|
||||||
</article>`);
|
</article>`);
|
||||||
})));
|
})));
|
||||||
const fd = fs.openSync("site/changelog/index.md", "w+");
|
|
||||||
|
let fd = fs.openSync("site/changelog/index.md", "w+");
|
||||||
fs.writeSync(fd,
|
fs.writeSync(fd,
|
||||||
`---
|
`---
|
||||||
title: Changelog
|
title: Changelog
|
||||||
|
@ -248,7 +295,18 @@ next: false
|
||||||
|
|
||||||
${entries.join("\n\n")}
|
${entries.join("\n\n")}
|
||||||
</section>
|
</section>
|
||||||
`
|
`);
|
||||||
);
|
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);
|
fs.closeSync(fd);
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"homepage": "https://www.thepaperpilot.org/thepaperpilot.github.io",
|
"homepage": "https://www.thepaperpilot.org/thepaperpilot.github.io",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"feed": "^4.2.2",
|
||||||
"flexsearch": "^0.7.43",
|
"flexsearch": "^0.7.43",
|
||||||
"run-script-os": "^1.1.6",
|
"run-script-os": "^1.1.6",
|
||||||
"vitepress": "^1.2.2",
|
"vitepress": "^1.2.2",
|
||||||
|
|
14
yarn.lock
14
yarn.lock
|
@ -749,6 +749,13 @@ estree-walker@^2.0.2:
|
||||||
resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz"
|
resolved "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz"
|
||||||
integrity sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==
|
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:
|
flexsearch@^0.7.43:
|
||||||
version "0.7.43"
|
version "0.7.43"
|
||||||
resolved "https://registry.yarnpkg.com/flexsearch/-/flexsearch-0.7.43.tgz#34f89b36278a466ce379c5bf6fb341965ed3f16c"
|
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/runtime-dom" "3.4.27"
|
||||||
"@vue/server-renderer" "3.4.27"
|
"@vue/server-renderer" "3.4.27"
|
||||||
"@vue/shared" "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"
|
||||||
|
|
Loading…
Reference in a new issue