From 7086bb46ef30d5669db0b02d647bb63d1f8ef8c0 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 18 Sep 2026 21:45:15 -0700 Subject: [PATCH] Include MDN content commit in metadata --- inputfiles/mdn.commit | 1 + scripts/fetch-mdn.js | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 inputfiles/mdn.commit diff --git a/inputfiles/mdn.commit b/inputfiles/mdn.commit new file mode 100644 index 000000000..d429c8603 --- /dev/null +++ b/inputfiles/mdn.commit @@ -0,0 +1 @@ +19497692665c3551b4097af5cd9f52f84564cefd diff --git a/scripts/fetch-mdn.js b/scripts/fetch-mdn.js index 6d39a16d2..a8f7c068f 100644 --- a/scripts/fetch-mdn.js +++ b/scripts/fetch-mdn.js @@ -10,9 +10,20 @@ if (!res.ok) { } const data = await res.json(); +const entries = Object.values(data); + +const latestEntry = entries.reduce((latest, entry) => + !latest || entry.modified > latest.modified ? entry : latest, +); +const commit = latestEntry?.source?.last_commit_url.match( + /\/commit\/([0-9a-f]{40})$/, +)?.[1]; +if (!commit) { + throw new Error("Could not determine the mdn/content commit"); +} // Filter and map the data -const filtered = Object.values(data) +const filtered = entries .filter((entry) => { const path = entry.mdn_url; return ( @@ -35,5 +46,9 @@ await fs.writeFile( new URL("../inputfiles/mdn.json", import.meta.url), JSON.stringify(filtered, null, 2), ); +await fs.writeFile( + new URL("../inputfiles/mdn.commit", import.meta.url), + `${commit}\n`, +); console.log("mdn.json updated!");