aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/components/StaticStylesheet.ts
blob: 065ee20d201860cdbe892c7ef5b72c1e5a211379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { join } from "@std/path";
import { Config } from "../config.ts";
import { Element, link } from "../dom.ts";
import { calculateFileHash } from "./utils.ts";

export default async function StaticStylesheet(
  { fileName, config }: { fileName: string; config: Config },
): Promise<Element> {
  const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
  const hash = await calculateFileHash(filePath);
  return link({ rel: "stylesheet", href: `${fileName}?h=${hash}` });
}