readme generator

This commit is contained in:
tree🌴 2024-02-13 13:21:19 +01:00
parent c502922fe9
commit eea53e0f6e
3 changed files with 48 additions and 0 deletions

View File

@ -6,5 +6,8 @@ build:
frontend: frontend:
cd web && npm install && npm run build cd web && npm install && npm run build
readme:
deno run --allow-all utils/readme.js
compile: compile:
cp -r web/dist/** dist cp -r web/dist/** dist

View File

@ -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). You can read more in our [documentation](https://docs.web3privacy.info/news/week-in-the-privacy).
* [Subscribe Now!](https://paragraph.xyz/@privacynews/subscribe) * [Subscribe Now!](https://paragraph.xyz/@privacynews/subscribe)
## Issues
<!-- ISSUES-START -->
| 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 | - |
<!-- ISSUES-END -->

33
utils/readme.js Normal file
View File

@ -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(
/<!-- ISSUES-START -->[\s\S]+<!-- ISSUES-END -->/m,
`<!-- ISSUES-START -->\n\n${out}\n\n<!-- ISSUES-END -->`
)
await Deno.writeTextFile('./README.md', readmeOut)
console.log(`README.md modified. Done.`)