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 `${page}${changes}`; + }).join("\n"); + + resolve( +`
+

${title}

+

Pushed on

+

+ + + + + + + + +${changes} + +
PageChanges
+

+

${summary}

+
`); + }))); + const fd = fs.openSync("site/changelog/index.md", "w+"); + fs.writeSync(fd, +`--- +title: Changelog +--- +
+

+Changelog + +

+

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")} +
+` +); + fs.closeSync(fd); })(); diff --git a/site/.vitepress/config.ts b/site/.vitepress/config.ts index 7da7fa43..94ae265a 100644 --- a/site/.vitepress/config.ts +++ b/site/.vitepress/config.ts @@ -28,6 +28,7 @@ module.exports = { ['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: 'manifest', href: '/site.webmanifest' }], + ['link', { rel: 'alternate', type: "text/mf2+html", href: '/changelog' }], ['meta', { name: 'og:description', content: 'The Paper Pilot portfolio site' }] ], lastUpdated: true,