/g, "
");
+
+ if (content !== original) {
+ writeFileSync(snackbarFile, content);
+ console.log(" Fixed snackbarjs self-closing div.");
+ } else {
+ console.log(" snackbarjs already fixed or pattern not found.");
+ }
+} catch (e) {
+ console.log(` Skipping snackbarjs fix (not installed or not found): ${e.message}`);
+}
+
+console.log("Postinstall complete.");
diff --git a/scripts/prepareGhPages.mjs b/scripts/prepareGhPages.mjs
new file mode 100644
index 0000000000..bca2b10f80
--- /dev/null
+++ b/scripts/prepareGhPages.mjs
@@ -0,0 +1,32 @@
+/**
+ * Prepares build/prod/index.html for GitHub Pages deployment.
+ * Adds Google Analytics and Structured Data.
+ * Replaces the Grunt copy:ghPages task.
+ *
+ * @author CyberChef Modernization
+ * @copyright Crown Copyright 2017
+ * @license Apache-2.0
+ */
+
+import { readFileSync, writeFileSync } from "fs";
+import { join } from "path";
+
+const buildDir = "build/prod";
+
+console.log("--- Preparing for GitHub Pages ---");
+
+let indexHtml = readFileSync(join(buildDir, "index.html"), "utf8");
+
+// Add Google Analytics code
+const gaHtml = readFileSync("src/web/static/ga.html", "utf8");
+indexHtml = indexHtml.replace("