From 7bb8c0ad32799b740b788c70e212632526a83b19 Mon Sep 17 00:00:00 2001 From: Artemy Date: Tue, 23 Jan 2024 21:09:44 +0300 Subject: [PATCH] add external support --- README.md | 3 +-- index.js | 27 ++++++++++++++++++--------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 1862a55..94d1e17 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -# CIM Engine map list +# CIMEngine map list 1. Political Map of the World ([worldMap](https://cimengine.github.io/map/?id=worldMap)) 2. Virtual Governments - Map of Virtual Countries from OOVC organisation. ([vgovernments](https://cimengine.github.io/map/?id=vgovernments)) 3. International Virtual Countries - Map of International Virtual Countries (League of Virtual Nations). ([ivc](https://cimengine.github.io/map/?id=ivc)) 4. Political Map of Dusiburg - Политическая карта Дусибурской Республики ([dusiburg](https://cimengine.github.io/map/?id=dusiburg)) -5. `OVN` map - Map of Virtual Countries ([movc](https://cimengine.github.io/map/?id=movc)) diff --git a/index.js b/index.js index 70fa92b..fdc9dc8 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,24 @@ const fs = require("fs"); -const index = JSON.parse(fs.readFileSync("./index.json", "utf-8")); +async function run() { + const index = JSON.parse(fs.readFileSync("./index.json", "utf-8")); -let readme = "# CIM Engine map list\n\n"; + let readme = "# CIMEngine map list\n\n"; -let k = 1; -for (let id in index) { - let item = index[id]; - readme += `${k++}. ${item.name} ${ - item.description ? `- ${item.description}` : "" - } ([${id}](https://cimengine.github.io/map/?id=${id}))\n`; + let k = 1; + for (let id in index) { + let item = index[id]; + + if (item.external) { + item = await (await fetch(item.external)).json(); + } + + readme += `${k++}. ${item.name} ${ + item.description ? `- ${item.description}` : "" + } ([${id}](https://cimengine.github.io/map/?id=${id}))\n`; + } + + fs.writeFileSync("./README.md", readme); } -fs.writeFileSync("./README.md", readme); +run();