From b98d324fe7eb37e7004926843feede7e636c3301 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 18 Mar 2023 17:17:11 +0900 Subject: refactor: move shared codes to templates/utils.ts --- nuldoc-src/templates/utils.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'nuldoc-src/templates/utils.ts') diff --git a/nuldoc-src/templates/utils.ts b/nuldoc-src/templates/utils.ts index 65dd506..018c460 100644 --- a/nuldoc-src/templates/utils.ts +++ b/nuldoc-src/templates/utils.ts @@ -33,3 +33,19 @@ export async function stylesheetLinkElement( const hash = toHashString(await crypto.subtle.digest("MD5", content), "hex"); return el("link", [["rel", "stylesheet"], ["href", `${fileName}?h=${hash}`]]); } + +export function metaElement(attrs: [string, string][]): Element { + return el("meta", attrs); +} + +export function linkElement( + rel: string, + href: string, + type: string | null, +): Element { + const attrs: [string, string][] = [["rel", rel], ["href", href]]; + if (type !== null) { + attrs.push(["type", type]); + } + return el("link", attrs); +} -- cgit v1.2.3-70-g09d2