Skip to content

Commit 54c45ce

Browse files
committed
docs: add inkeep search bar
1 parent 268691b commit 54c45ce

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

docs/script.js

+114
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
"use client";
2+
3+
// Get the Mintlify search containers, going to reuse them as the triggers for Inkeep
4+
const searchButtonContainerIds = [
5+
"search-bar-entry",
6+
"search-bar-entry-mobile",
7+
];
8+
9+
// Clone and replace, needed to remove existing event listeners
10+
const clonedSearchButtonContainers = searchButtonContainerIds.map((id) => {
11+
const originalElement = document.getElementById(id);
12+
const clonedElement = originalElement.cloneNode(true);
13+
14+
originalElement.parentNode.replaceChild(clonedElement, originalElement);
15+
16+
return clonedElement;
17+
});
18+
19+
// Load the Inkeep script
20+
const inkeepScript = document.createElement("script");
21+
inkeepScript.type = "module";
22+
inkeepScript.src =
23+
"https://unpkg.com/@inkeep/[email protected]/dist/embed.js";
24+
document.body.appendChild(inkeepScript);
25+
26+
// Once the Inkeep script has loaded, load the Inkeep chat components
27+
inkeepScript.addEventListener("load", function () {
28+
// Customization settings
29+
const sharedConfig = {
30+
baseSettings: {
31+
apiKey: "9b77dccb6cacb770614645da24b68c168dc213967b015a6f",
32+
integrationId: "clt6g42dh0008hl8duk922fjd",
33+
organizationId: "org_hCC6MgTLBCh3juv4",
34+
primaryBrandColor: "#8143E3",
35+
},
36+
aiChatSettings: {
37+
chatSubjectName: "Activepieces",
38+
botAvatarSrcUrl:
39+
"https://storage.googleapis.com/organization-image-assets/activepieces-botAvatarSrcUrl-1709136841325.svg",
40+
botAvatarDarkSrcUrl:
41+
"https://storage.googleapis.com/organization-image-assets/activepieces-botAvatarDarkSrcUrl-1709136840372.svg",
42+
getHelpCallToActions: [
43+
{
44+
name: "Discord",
45+
url: "https://discord.gg/2jUXBKDdP8",
46+
icon: {
47+
builtIn: "FaDiscord",
48+
},
49+
},
50+
{
51+
name: "Community",
52+
url: "https://community.activepieces.com/",
53+
icon: {
54+
builtIn: "IoPeopleOutline",
55+
},
56+
},
57+
{
58+
name: "GitHub",
59+
url: "https://github.com/activepieces/activepieces",
60+
icon: {
61+
builtIn: "FaGithub",
62+
},
63+
},
64+
],
65+
quickQuestions: [
66+
"How do I conditionally change a flow?",
67+
"Can I incorporate custom external APIs?",
68+
"How do I monitor usage?",
69+
],
70+
},
71+
};
72+
73+
// for syncing with dark mode
74+
const colorModeSettings = {
75+
observedElement: document.documentElement,
76+
isDarkModeCallback: (el) => {
77+
return el.classList.contains("dark");
78+
},
79+
colorModeAttribute: "class",
80+
};
81+
82+
// add the "Ask AI" pill chat button
83+
Inkeep().embed({
84+
componentType: "ChatButton",
85+
colorModeSync: colorModeSettings,
86+
properties: sharedConfig,
87+
});
88+
89+
// instantiate Inkeep "custom trigger" component
90+
const inkeepSearchModal = Inkeep({
91+
...sharedConfig.baseSettings,
92+
}).embed({
93+
componentType: "CustomTrigger",
94+
colorModeSync: colorModeSettings,
95+
properties: {
96+
...sharedConfig,
97+
isOpen: false,
98+
onClose: () => {
99+
inkeepSearchModal.render({
100+
isOpen: false,
101+
});
102+
},
103+
},
104+
});
105+
106+
// When the Mintlify search bar clone is clicked, open the Inkeep search modal
107+
clonedSearchButtonContainers.forEach((trigger) => {
108+
trigger.addEventListener("click", function () {
109+
inkeepSearchModal.render({
110+
isOpen: true,
111+
});
112+
});
113+
});
114+
});

0 commit comments

Comments
 (0)