From eea53e0f6ef8be81bd786f4b61695a2bd31367a1 Mon Sep 17 00:00:00 2001 From: tree Date: Tue, 13 Feb 2024 13:21:19 +0100 Subject: [PATCH] readme generator --- Makefile | 3 +++ README.md | 12 ++++++++++++ utils/readme.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 utils/readme.js diff --git a/Makefile b/Makefile index de0274e..c353158 100644 --- a/Makefile +++ b/Makefile @@ -6,5 +6,8 @@ build: frontend: cd web && npm install && npm run build +readme: + deno run --allow-all utils/readme.js + compile: cp -r web/dist/** dist \ No newline at end of file diff --git a/README.md b/README.md index 515dd41..ec958c8 100644 --- a/README.md +++ b/README.md @@ -9,3 +9,15 @@ This repository serves as the source for the [Week in The Privacy News](https:// You can read more in our [documentation](https://docs.web3privacy.info/news/week-in-the-privacy). * [Subscribe Now!](https://paragraph.xyz/@privacynews/subscribe) + +## Issues + + + +| Week | Period | Deadline | Curator | +| --- | --- | --- | --- | +| [2024-07](/data/2024/week07.md) | Feb 12 - Feb 18, 2024 | Feb 18 | Mykola | +| [2024-06](/data/2024/week06.md) | Feb 5 - Feb 11, 2024 | ✅ published | Tree | +| [2024-05](/data/2024/week05.md) | Jan 29 - Feb 4, 2024 | ✅ published | - | + + \ No newline at end of file diff --git a/utils/readme.js b/utils/readme.js new file mode 100644 index 0000000..76476d6 --- /dev/null +++ b/utils/readme.js @@ -0,0 +1,33 @@ +import { setWeek, nextMonday, format, addDays } from 'npm:date-fns'; + +const issues = JSON.parse(await Deno.readTextFile('./dist/index.json')) + +const lines = [] + +lines.push('| Week | Period | Deadline | Curator |') +lines.push('| --- | --- | --- | --- |') + +for (const issue of issues) { + const [ year, week ] = issue.week.split('-') + const props = [ + `[${issue.week}](/data/${year}/week${week}.md)`, + `${format(new Date(issue.period[0]), "MMM d")} - ${format(new Date(issue.period[1]), "MMM d, yyyy")}`, + issue.published ? '✅ published' : format(new Date(issue.period[1]), "MMM d"), + issue.curator || '-' + ] + + lines.push('| ' + props.join(' | ') + ' |') +} + +const out = lines.join("\n") +//console.log(out) + +const readmeSrc = await Deno.readTextFile('./README.md') +const readmeOut = readmeSrc.replace( + /[\s\S]+/m, + `\n\n${out}\n\n` +) + +await Deno.writeTextFile('./README.md', readmeOut) + +console.log(`README.md modified. Done.`) \ No newline at end of file