summaryrefslogtreecommitdiffhomepage
path: root/vhosts/blog/nuldoc-src/components/StaticScript.tsx
blob: e3b103cc89ccf907a4a4431015a6f35c69b97791 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { join } from "@std/path";
import { Config } from "../config.ts";
import { calculateFileHash } from "./utils.ts";

export default async function StaticScript(
  { fileName, type, config }: {
    fileName: string;
    type?: string;
    config: Config;
  },
) {
  const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
  const hash = await calculateFileHash(filePath);
  return (
    <script src={`${fileName}?h=${hash}`} {...(type ? { type } : {})}></script>
  );
}