Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions inputfiles/mdn.commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
19497692665c3551b4097af5cd9f52f84564cefd
17 changes: 16 additions & 1 deletion scripts/fetch-mdn.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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!");
Loading