-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
32 lines (29 loc) · 902 Bytes
/
utils.js
File metadata and controls
32 lines (29 loc) · 902 Bytes
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
// @ts-check
// deno-lint-ignore-file no-import-prefix
/**
* @import { BundledLanguage } from "https://esm.sh/shiki@4.0.2"
*/
/**
* @param {string} url
* @param {BundledLanguage} lang
* @param {AbortSignal} [signal]
*/
export async function fetchSourceHTML(url, lang, signal) {
const [{ codeToHtml }, source] = await Promise.all([
import("https://esm.sh/shiki@4.0.2"),
fetch(url, { signal }).then((res) => res.text()),
]);
const html = await codeToHtml(source, { lang, theme: "nord" });
signal?.throwIfAborted();
return html;
}
/** @param {AbortSignal} [signal] */
export async function fetchReadmeHTML(signal) {
const [{ parse }, readmeMarkdown] = await Promise.all([
import("https://esm.sh/*marked@17.0.0"),
fetch("./README.md", { signal }).then((res) => res.text()),
]);
const html = await parse(readmeMarkdown);
signal?.throwIfAborted();
return html;
}