Add changelog page/feed
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 11s
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 11s
This commit is contained in:
parent
eebdb59854
commit
923b40ed47
3 changed files with 66 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,4 +2,5 @@ node_modules
|
||||||
site/.vitepress/dist
|
site/.vitepress/dist
|
||||||
site/.vitepress/cache
|
site/.vitepress/cache
|
||||||
site/public/garden/
|
site/public/garden/
|
||||||
|
site/changelog/index.md
|
||||||
garden-output/
|
garden-output/
|
|
@ -1,6 +1,9 @@
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
|
|
||||||
|
const util = require('node:util');
|
||||||
|
const exec = util.promisify(require('node:child_process').exec);
|
||||||
|
|
||||||
function walk(dir, cb) {
|
function walk(dir, cb) {
|
||||||
const list = fs.readdirSync(dir);
|
const list = fs.readdirSync(dir);
|
||||||
return Promise.all(list.map(file => {
|
return Promise.all(list.map(file => {
|
||||||
|
@ -184,4 +187,65 @@ function toSlug(string) {
|
||||||
fs.rmSync('./site/garden/guide-to-incrementals/what-is-content-', { recursive: true });
|
fs.rmSync('./site/garden/guide-to-incrementals/what-is-content-', { recursive: true });
|
||||||
fs.mkdirSync('./site/guide-to-incrementals/ludology/definition');
|
fs.mkdirSync('./site/guide-to-incrementals/ludology/definition');
|
||||||
fs.copyFileSync('./site/garden/guide-to-incrementals/defining-the-genre/index.md', './site/guide-to-incrementals/ludology/definition/index.md');
|
fs.copyFileSync('./site/garden/guide-to-incrementals/defining-the-genre/index.md', './site/guide-to-incrementals/ludology/definition/index.md');
|
||||||
|
|
||||||
|
// Build changelog
|
||||||
|
fs.mkdirSync("./site/changelog");
|
||||||
|
|
||||||
|
const { stdout } = await exec('git log --after="2024-06-03T0:0:0+0000" --pretty=%H site/garden');
|
||||||
|
const entries = await Promise.all(stdout.split("\n").filter(p => p).map(hash => new Promise(async (resolve) => {
|
||||||
|
const { stdout: title } = await exec(`git show --quiet --format=%s ${hash}`);
|
||||||
|
const { stdout: time } = await exec(`git show --quiet --format=%as ${hash}`);
|
||||||
|
let { stdout: changes } = await exec(`git show --format="" --stat=100 --relative ${hash} .`, { cwd: 'site/garden' });
|
||||||
|
|
||||||
|
changes = changes.replaceAll(/\/index.md/g, '');
|
||||||
|
changes = changes.replaceAll(
|
||||||
|
/(\| +[0-9]+ )(\++)/g,
|
||||||
|
'$1<span style="color:#A3BE8C">$2</span>');
|
||||||
|
changes = changes.replaceAll(
|
||||||
|
/(\| +[0-9]+ \+*)(-+)/g,
|
||||||
|
'$1<span style="color:#BF616A">$2</span>');
|
||||||
|
const lines = changes.split('\n');
|
||||||
|
const summary = lines[lines.length - 2];
|
||||||
|
changes = lines.slice(0, -2).map(line => {
|
||||||
|
const [page, changes] = line.split("|").map(p => p.trim());
|
||||||
|
return `<tr><td><a href="/garden/${page}">${page}</a></td><td>${changes}</td></tr>`;
|
||||||
|
}).join("\n");
|
||||||
|
|
||||||
|
resolve(
|
||||||
|
`<article class="h-entry">
|
||||||
|
<h2 class="p-name">${title}</h2>
|
||||||
|
<p>Pushed on <time class="dt-published">${time}</time></p>
|
||||||
|
<p class="p-content">
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th style="align: center">Page</th>
|
||||||
|
<th style="align: center">Changes</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
${changes}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
<p>${summary}</p>
|
||||||
|
</article>`);
|
||||||
|
})));
|
||||||
|
const fd = fs.openSync("site/changelog/index.md", "w+");
|
||||||
|
fs.writeSync(fd,
|
||||||
|
`---
|
||||||
|
title: Changelog
|
||||||
|
---
|
||||||
|
<section class="h-feed">
|
||||||
|
<h1 class="p-name">
|
||||||
|
<a href="/changelog" class="u-url">Changelog</a>
|
||||||
|
<a href="/changelog.rss"><svg viewBox="0 0 16 16" class="svg octicon-rss" aria-hidden="true" width="16" height="16"><path d="M2.002 2.725a.75.75 0 0 1 .797-.699C8.79 2.42 13.58 7.21 13.974 13.201a.75.75 0 0 1-1.497.098 10.5 10.5 0 0 0-9.776-9.776.747.747 0 0 1-.7-.798ZM2.84 7.05h-.002a7 7 0 0 1 6.113 6.111.75.75 0 0 1-1.49.178 5.5 5.5 0 0 0-4.8-4.8.75.75 0 0 1 .179-1.489M2 13a1 1 0 1 1 2 0 1 1 0 0 1-2 0"></path></svg></a>
|
||||||
|
</h1>
|
||||||
|
<p>This feed starts when I formatted the site to be a <a href="/garden/digital-garden/">Digital Garden</a>. If you'd like to look further into this site's history, check <a href="https://code.incremental.social/thepaperpilot/pages/commits/branch/master">here</a>!</p>
|
||||||
|
|
||||||
|
${entries.join("\n\n")}
|
||||||
|
</section>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
fs.closeSync(fd);
|
||||||
})();
|
})();
|
||||||
|
|
|
@ -28,6 +28,7 @@ module.exports = {
|
||||||
['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
|
['link', { rel: 'preconnect', href: 'https://fonts.googleapis.com' }],
|
||||||
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Pacifico&family=Roboto+Mono:ital,wght@0,400;0,600;1,400&display=swap' }],
|
['link', { rel: 'stylesheet', href: 'https://fonts.googleapis.com/css2?family=Pacifico&family=Roboto+Mono:ital,wght@0,400;0,600;1,400&display=swap' }],
|
||||||
['link', { rel: 'manifest', href: '/site.webmanifest' }],
|
['link', { rel: 'manifest', href: '/site.webmanifest' }],
|
||||||
|
['link', { rel: 'alternate', type: "text/mf2+html", href: '/changelog' }],
|
||||||
['meta', { name: 'og:description', content: 'The Paper Pilot portfolio site' }]
|
['meta', { name: 'og:description', content: 'The Paper Pilot portfolio site' }]
|
||||||
],
|
],
|
||||||
lastUpdated: true,
|
lastUpdated: true,
|
||||||
|
|
Loading…
Reference in a new issue