news/utils/readme.js

33 lines
1.1 KiB
JavaScript
Raw Normal View History

2024-02-13 13:21:19 +01:00
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)`,
2024-02-13 13:26:01 +01:00
`${format(new Date(issue.period[0]), "MMM d")} - ${format(new Date(issue.period[1]), "MMM d")}`,
2024-02-13 13:23:40 +01:00
issue.published ? `✅ [published](https://news.web3privacy.info/${issue.week})` : format(new Date(issue.period[1]), "MMM d"),
2024-02-13 13:21:19 +01:00
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.`)