generated from mintlify/starter
-
Notifications
You must be signed in to change notification settings - Fork 1
/
script.js
executable file
·117 lines (105 loc) · 3.43 KB
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
"use client";
// Load the Inkeep script
const inkeepScript = document.createElement("script");
inkeepScript.type = "module";
inkeepScript.src =
"https://unpkg.com/@inkeep/[email protected]/dist/embed.js";
document.body.appendChild(inkeepScript);
// find the Mintlify search container
const buttons = Array.from(document.getElementsByTagName("button"));
const searchButtonContainerEl = buttons.find((button) =>
button.textContent.includes("Search or ask...")
);
const clonedSearchButtonContainerEl = searchButtonContainerEl.cloneNode(true);
// replace with dummy div, required to remove event listeners on it
searchButtonContainerEl.parentNode.replaceChild(
clonedSearchButtonContainerEl,
searchButtonContainerEl
);
// Once the script has loaded, load the Inkeep chat components
inkeepScript.addEventListener("load", function () {
// Settings for the components
const sharedConfig = {
baseSettings: {
apiKey: "c99c3754a78cf9f7d3d389ef9fa7c3d49cdeb18b95050d10",
integrationId: "cltexfnd9000iy0ufy9oqo6h6",
organizationId: "org_VKqv6JAjdI85T7aJ",
primaryBrandColor: "#0c0c0c",
},
aiChatSettings: {
chatSubjectName: "Nixtla",
botAvatarSrcUrl:
"https://storage.googleapis.com/organization-image-assets/nixtla-botAvatarSrcUrl-1709853122420.png",
botAvatarDarkSrcUrl:
"https://storage.googleapis.com/organization-image-assets/nixtla-botAvatarDarkSrcUrl-1709853121631.png",
getHelpCallToActions: [
{
name: "Ask on Slack",
url: "https://join.slack.com/t/nixtlaworkspace/shared_invite/zt-135dssye9-fWTzMpv2WBthq8NK0Yvu6A",
icon: {
builtIn: "FaSlack",
},
},
{
name: "View Repositories",
url: "https://github.com/Nixtla",
icon: {
builtIn: "FaGithub",
},
},
],
quickQuestions: [
"How do I train my own model using mlforecast?",
"How was TimeGPT trained and what's it best for?",
"How do I make multivariate scoring for hierarchical forecasting?",
],
},
};
// for syncing with dark mode
const colorModeSettings = {
observedElement: document.documentElement,
isDarkModeCallback: (el) => {
return el.classList.contains("dark");
},
colorModeAttribute: "class",
};
// add the chat button
const chatButton = Inkeep().embed({
componentType: "ChatButton",
colorModeSync: colorModeSettings,
properties: sharedConfig,
});
// insantiate Inkeep modal
const searchButtonWithCustomTrigger = Inkeep({
...sharedConfig.baseSettings,
}).embed({
componentType: "CustomTrigger",
colorModeSync: colorModeSettings,
properties: {
...sharedConfig,
isOpen: false,
onClose: () => {
searchButtonWithCustomTrigger.render({
isOpen: false,
});
},
},
});
// When the Mintlify search bar clone is clicked, open the Inkeep search modal
clonedSearchButtonContainerEl.addEventListener("click", function () {
searchButtonWithCustomTrigger.render({
isOpen: true,
});
});
});
!(function (t) {
if (window.oneloop) return;
window.oneloop = {key: "cus_b57d16380d7240e4a47c9f4a6f0893c6"};
var n = document.createElement("script");
(n.async = !0),
n.setAttribute(
"src",
"https://oneloop-website-script.s3.us-west-1.amazonaws.com/oneloop-main.js"
),
(document.body || document.head).appendChild(n);
})();