From bba5b9d2d05809fd86854611eefc1bb6e7f44440 Mon Sep 17 00:00:00 2001 From: "D. Bohdan" Date: Tue, 11 Jul 2023 16:30:32 +0000 Subject: [PATCH] gen-readme: add field "note"; make "demo" optional --- gen-readme.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gen-readme.ts b/gen-readme.ts index 9385e9a..1ab770f 100755 --- a/gen-readme.ts +++ b/gen-readme.ts @@ -10,6 +10,7 @@ type Item = { demo: string; github: string; name: string; + note: string; screenshots: string[]; website: string; }; @@ -32,13 +33,14 @@ const readData = async (...args: string[]): Promise => { }; const renderItem = ( - { demo, github, name, screenshots, website }: Item, + { demo, github, name, note, screenshots, website }: Item, ): string => { const screenshotMarkdown = screenshots.map((filename) => `[![${filename}](thumbnail/${filename})](screenshot/${filename})` ).join("\n"); return `### ${name}\n\n` + + (note === "" ? "" : `${note}\n\n`) + (website === "" ? "" : `* [Website](${website})\n`) + (github === "" ? "" @@ -47,7 +49,8 @@ const renderItem = ( `![Last commit](https://img.shields.io/github/last-commit/${github}?style=flat-square) ` + `![GitHub open issues](https://img.shields.io/github/issues-raw/${github}?style=flat-square) ` + `![GitHub closed issues](https://img.shields.io/github/issues-closed-raw/${github}?style=flat-square)\n`) + - `* [Demo](${demo})\n\n${screenshotMarkdown}`; + (demo === "" ? "" : `* [Demo](${demo})\n\n`) + + screenshotMarkdown; }; try { @@ -66,6 +69,7 @@ try { demo: await readData(sectionDir, itemDir, "demo"), github: await readData(sectionDir, itemDir, "github"), name: await readData(sectionDir, itemDir, "name"), + note: await readData(sectionDir, itemDir, "note"), screenshots: (await readData(sectionDir, itemDir, "screenshots")).split( "\n", ),