diff --git a/blog.html b/blog.html
index bd41b469..395c5be8 100644
--- a/blog.html
+++ b/blog.html
@@ -34,6 +34,7 @@
+
diff --git a/js/index.js b/js/index.js
index 64d41275..d86228d1 100644
--- a/js/index.js
+++ b/js/index.js
@@ -298,9 +298,6 @@ function handleQueryParams() {
}
}
-/**
- * Handle #view=... in the hash and load the correct partial view.
- */
function handleHashChange() {
console.log("handleHashChange called, current hash =", window.location.hash);
@@ -327,11 +324,11 @@ function handleHashChange() {
// Now dynamically load that partial, then call its init function
import("./viewManager.js").then(({ loadView, viewInitRegistry }) => {
- loadView(viewUrl).then(() => {
- const initFn = viewInitRegistry[viewName];
- if (typeof initFn === "function") {
- initFn();
- }
- });
+ loadView(viewUrl).then(() => {
+ const initFn = viewInitRegistry[viewName];
+ if (typeof initFn === "function") {
+ initFn();
+ }
+ });
});
}
diff --git a/js/tracking.js b/js/tracking.js
new file mode 100644
index 00000000..f19158c7
--- /dev/null
+++ b/js/tracking.js
@@ -0,0 +1,41 @@
+// js/tracking.js
+// Centralized configuration and loader for the site's analytics script.
+// Update `bitvidTrackingConfig` to change the tracking provider or settings.
+window.bitvidTrackingConfig = window.bitvidTrackingConfig || {
+ src: "https://umami.malin.onl/script.js",
+ websiteId: "1f8eead2-79f0-4dba-8c3b-ed9b08b6e877",
+};
+
+(function loadTrackingScript(config) {
+ if (!config || !config.src) {
+ return;
+ }
+
+ if (document.querySelector(`script[src="${config.src}"]`)) {
+ return;
+ }
+
+ const script = document.createElement("script");
+ script.src = config.src;
+ script.defer = true;
+
+ if (config.websiteId) {
+ script.setAttribute("data-website-id", config.websiteId);
+ }
+
+ const additionalAttributes = config.attributes || {};
+ Object.entries(additionalAttributes).forEach(([key, value]) => {
+ if (key === "defer") {
+ script.defer = Boolean(value);
+ return;
+ }
+
+ if (value === false || value === null || typeof value === "undefined") {
+ return;
+ }
+
+ script.setAttribute(key, value);
+ });
+
+ document.head.appendChild(script);
+})(window.bitvidTrackingConfig);
diff --git a/tests/nostr-ephemeral-dm-tester.html b/tests/nostr-ephemeral-dm-tester.html
index 4c908ae9..2a97cfa2 100644
--- a/tests/nostr-ephemeral-dm-tester.html
+++ b/tests/nostr-ephemeral-dm-tester.html
@@ -3,6 +3,7 @@
Nostr Ephemeral DM Tester (Using finalizeEvent)
+