aboutsummaryrefslogtreecommitdiffhomepage
path: root/nuldoc-src/templates/utils.ts
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2023-03-18 18:09:50 +0900
committernsfisis <nsfisis@gmail.com>2023-03-18 18:12:23 +0900
commit12035272d44d92cd2360aeff88d499db67fe1949 (patch)
treeb9366110badb650b7d0af84330dd69df4bd71bcf /nuldoc-src/templates/utils.ts
parentb98d324fe7eb37e7004926843feede7e636c3301 (diff)
downloadblog.nsfisis.dev-12035272d44d92cd2360aeff88d499db67fe1949.tar.gz
blog.nsfisis.dev-12035272d44d92cd2360aeff88d499db67fe1949.tar.zst
blog.nsfisis.dev-12035272d44d92cd2360aeff88d499db67fe1949.zip
refactor: use Page instead of Document
Diffstat (limited to 'nuldoc-src/templates/utils.ts')
-rw-r--r--nuldoc-src/templates/utils.ts51
1 files changed, 0 insertions, 51 deletions
diff --git a/nuldoc-src/templates/utils.ts b/nuldoc-src/templates/utils.ts
deleted file mode 100644
index 018c460..0000000
--- a/nuldoc-src/templates/utils.ts
+++ /dev/null
@@ -1,51 +0,0 @@
-import { join } from "std/path/mod.ts";
-import { crypto, toHashString } from "std/crypto/mod.ts";
-import { Element, Node, Text } from "../dom.ts";
-import { Config } from "../config.ts";
-
-export function text(content: string): Text {
- return {
- kind: "text",
- content: content,
- raw: false,
- };
-}
-
-export function el(
- name: string,
- attrs: [string, string][],
- ...children: Node[]
-): Element {
- return {
- kind: "element",
- name: name,
- attributes: new Map(attrs),
- children: children,
- };
-}
-
-export async function stylesheetLinkElement(
- fileName: string,
- config: Config,
-): Promise<Element> {
- const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
- const content = (await Deno.readFile(filePath)).buffer;
- 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);
-}