${title}
+Pushed on
++
Page | +Changes | +
---|
${summary}
+diff --git a/.gitignore b/.gitignore index f68f3228..e7231360 100755 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ node_modules site/.vitepress/dist site/.vitepress/cache site/public/garden/ +site/changelog/index.md garden-output/ \ No newline at end of file diff --git a/build_garden.js b/build_garden.js index 9d68a3d3..fdfe3e62 100644 --- a/build_garden.js +++ b/build_garden.js @@ -1,6 +1,9 @@ const fs = require("fs"); const path = require("path"); +const util = require('node:util'); +const exec = util.promisify(require('node:child_process').exec); + function walk(dir, cb) { const list = fs.readdirSync(dir); 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.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'); + + // 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$2'); + changes = changes.replaceAll( + /(\| +[0-9]+ \+*)(-+)/g, + '$1$2'); + 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 `
Pushed on
++
Page | +Changes | +
---|
${summary}
+This feed starts when I formatted the site to be a Digital Garden. If you'd like to look further into this site's history, check here!
+ +${entries.join("\n\n")} +