From 1c7f3c1ab901ae1f7e9198c4dc6e30dffadc05ff Mon Sep 17 00:00:00 2001 From: cqb13 Date: Tue, 23 Jul 2024 16:58:46 -0400 Subject: [PATCH] fix name and description --- loadPrograms.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/loadPrograms.js b/loadPrograms.js index 3623f8a..d83d3a2 100644 --- a/loadPrograms.js +++ b/loadPrograms.js @@ -32,6 +32,30 @@ const loadPrograms = async () => { txt_file_url = file.html_url; } else if (file.name === "about.md") { const aboutResponse = await fetch(file.download_url); + + const aboutText = await aboutResponse.text(); + + const aboutLines = aboutText.split("\n"); + + let descriptionLines = []; + let descriptionStarted = false; + for (const line of aboutLines) { + if (line.startsWith("# ")) { + name = line.substring(2); + descriptionStarted = true; + continue; + } + + if (line.startsWith("#")) { + descriptionStarted = false; + } + + if (descriptionStarted && line != "") { + descriptionLines.push(line); + } + } + + description = descriptionLines.join(" "); } }