aboutsummaryrefslogtreecommitdiffhomepage
path: root/services/nuldoc/nuldoc-src/components/StaticStylesheet.ts
blob: 43802d2f7caad5f95ebc3252049a2a444b10dfbd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
import { join } from "@std/path";
import { Config } from "../config.ts";
import { elem, Element } 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 elem("link", { rel: "stylesheet", href: `${fileName}?h=${hash}` });
}