diff --git a/html.ts b/html.ts index ef55a23f1..80f0c89a5 100644 --- a/html.ts +++ b/html.ts @@ -1,65 +1,86 @@ -import util from './util.ts' +import util from "./util.ts"; export function createHtml({ - lang = 'en', + lang = "en", head = [], scripts = [], body, - minify = false + minify = false, }: { - lang?: string, - head?: string[], - scripts?: (string | { id?: string, type?: string, src?: string, innerText?: string, nomodule?: boolean, async?: boolean, preload?: boolean })[], - body: string, - minify?: boolean + lang?: string; + head?: string[]; + scripts?: + (string | { + id?: string; + type?: string; + src?: string; + innerText?: string; + nomodule?: boolean; + async?: boolean; + preload?: boolean; + })[]; + body: string; + minify?: boolean; }) { - const eol = minify ? '' : '\n' - const indent = minify ? '' : ' '.repeat(4) - const headTags = head.map(tag => tag.trim()) - .concat(scripts.map(v => { + const eol = minify ? "" : "\n"; + const indent = minify ? "" : " ".repeat(4); + const headTags = head.map((tag) => tag.trim()) + .concat(scripts.map((v) => { if (!util.isString(v) && util.isNEString(v.src)) { - if (v.type === 'module') { - return `` - } else if (v.async === true) { - return `` + if (v.type === "module") { + return ``; } + return ``; } - return '' - })).filter(Boolean) - const scriptTags = scripts.map(v => { + return ""; + })) + /*.concat( + [ + "/_aleph/-/deno.land/x/aleph/error.js", + "/_aleph/-/deno.land/x/aleph/aleph.js", + "/_aleph/-/deno.land/x/aleph/context.js", + "/_aleph/-/deno.land/x/aleph/events.js" + ].map((v) => + `` + ), + )*/ + .filter(Boolean); + const scriptTags = scripts.map((v) => { if (util.isString(v)) { - return `` + return ``; } else if (util.isNEString(v.innerText)) { - const { innerText, ...rest } = v - return `` + const { innerText, ...rest } = v; + return ``; } else if (util.isNEString(v.src) && !v.preload) { - return `` + return ``; } else { - return '' + return ""; } - }).filter(Boolean) + }).filter(Boolean); return [ - '', + "", ``, - '
', + "", indent + '', - ...headTags.map(tag => indent + tag), - '', - '', + ...headTags.map((tag) => indent + tag), + "", + "", indent + body, - ...scriptTags.map(tag => indent + tag), - '', - '' - ].join(eol) + ...scriptTags.map((tag) => indent + tag), + "", + "