-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown.ts
32 lines (30 loc) · 1.02 KB
/
markdown.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/** @format */
import axios from "axios";
import marked = require("marked");
// Gets MD content from a tasks table
function get_task_content(tasks_to_extract: any): Promise<any[]> {
const tasks_with_promises: [] = tasks_to_extract
.filter(
(task) =>
task["task summary url"].includes(".md") &&
task["task summary url"].includes("https://") &&
task.phase == "2"
)
.map(async (task) => {
task.url = task["task summary url"]
.replace("https://github.com/", "https://raw.githubusercontent.com/")
.replace("/blob/", "/")
.replace(" ", "");
task.content = await axios.get(task.url)
.then((res) => res.data)
.then((md) => marked(md));
return task;
});
return Promise.all(tasks_with_promises);
}
// Filters out broken tasks
export const get_renderable_tasks = async (tasks_to_extract) => {
return (await get_task_content(tasks_to_extract)).filter(
(task) => !task.content.includes("404: Not Found")
);
};