Skip to content

Commit c4a5bdc

Browse files
authored
feat: add intercom (axelarnetwork#1201)
1 parent aecf625 commit c4a5bdc

File tree

4 files changed

+56
-2
lines changed

4 files changed

+56
-2
lines changed

astro.config.mjs

+4-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ export default defineConfig({
3030
}),
3131
],
3232
site: "https://docs.axelar.dev",
33-
33+
trailingSlash: "always",
34+
devToolbar: {
35+
enabled: false,
36+
},
3437
markdown: {
3538
remarkPlugins: [
3639
remarkDirective,

src/layouts/MainLayout.astro

+7-1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,12 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
9595

9696
gtag("config", "G-81ZT0BK1ZB");
9797
</script>
98+
<script>
99+
window.intercomSettings = {
100+
api_base: "https://api-iam.intercom.io",
101+
app_id: "rxsoqwkv",
102+
};
103+
</script>
98104
<script src="/src/scripts/index.ts"></script>
99105
<script is:inline>
100106
const root = document.documentElement;
@@ -157,7 +163,7 @@ const canonicalURL = new URL(Astro.url.pathname, Astro.site);
157163
localStorage.setItem("theme", isDark ? "dark" : "light");
158164
document.documentElement.setAttribute(
159165
"data-theme",
160-
isDark ? "vitesse-dark" : "light-plus",
166+
isDark ? "vitesse-dark" : "light-plus"
161167
);
162168
};
163169

src/scripts/index.ts

+2
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ import "./prism.js";
99
import "./safelinks";
1010
import { showToast } from "./toast";
1111
import "./wrapTables";
12+
import "./intercom";
13+
1214
window["showToast"] = showToast;

src/scripts/intercom.ts

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
function loadIntercom() {
2+
(function () {
3+
const w: any = window;
4+
const ic = w.Intercom;
5+
if (typeof ic === "function") {
6+
ic("reattach_activator");
7+
ic("update", w.intercomSettings);
8+
} else {
9+
const d = document;
10+
const i = function () {
11+
i.c(arguments);
12+
};
13+
i.q = [];
14+
i.c = function (args) {
15+
i.q.push(args);
16+
};
17+
w.Intercom = i;
18+
const s = d.createElement("script");
19+
s.type = "text/javascript";
20+
s.async = true;
21+
s.src = "https://widget.intercom.io/widget/rxsoqwkv";
22+
const x = d.getElementsByTagName("script")[0];
23+
if (x && x.parentNode) {
24+
x.parentNode.insertBefore(s, x);
25+
console.log("intercom loading.");
26+
}
27+
}
28+
})();
29+
}
30+
31+
function checkAndLoadIntercom() {
32+
if (document.readyState === "complete") {
33+
// Wait 15 seconds after document ready and network idle
34+
setTimeout(loadIntercom, 15000);
35+
}
36+
}
37+
38+
// Check for document ready and network idle
39+
if (document.readyState === "complete") {
40+
checkAndLoadIntercom();
41+
} else {
42+
window.addEventListener("load", checkAndLoadIntercom, false);
43+
}

0 commit comments

Comments
 (0)