summaryrefslogtreecommitdiffhomepage
path: root/services/blog/nuldoc-src/components/StaticScript.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'services/blog/nuldoc-src/components/StaticScript.tsx')
-rw-r--r--services/blog/nuldoc-src/components/StaticScript.tsx18
1 files changed, 18 insertions, 0 deletions
diff --git a/services/blog/nuldoc-src/components/StaticScript.tsx b/services/blog/nuldoc-src/components/StaticScript.tsx
new file mode 100644
index 00000000..0e3ab194
--- /dev/null
+++ b/services/blog/nuldoc-src/components/StaticScript.tsx
@@ -0,0 +1,18 @@
+import { join } from "@std/path";
+import { Config } from "../config.ts";
+import { calculateFileHash } from "./utils.ts";
+
+export default async function StaticScript(
+ { fileName, type, defer, config }: {
+ fileName: string;
+ type?: string;
+ defer?: "true";
+ config: Config;
+ },
+) {
+ const filePath = join(Deno.cwd(), config.locations.staticDir, fileName);
+ const hash = await calculateFileHash(filePath);
+ return (
+ <script src={`${fileName}?h=${hash}`} type={type} defer={defer}></script>
+ );
+}