Skip to content

Commit ce3d5d7

Browse files
committed
add chatbot
1 parent 854bae9 commit ce3d5d7

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/theme/Root.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React, { useEffect } from 'react';
2+
3+
// Default implementation, that you can customize
4+
export default function Root({ children }) {
5+
6+
useEffect(() => {
7+
// Paste the embed script here:
8+
window.DocsBotAI=window.DocsBotAI||{},DocsBotAI.init=function(e){return new Promise((t,r)=>{var n=document.createElement("script");n.type="text/javascript",n.async=!0,n.src="https://widget.docsbot.ai/chat.js";let o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(n,o),n.addEventListener("load",()=>{let n;Promise.all([new Promise((t,r)=>{window.DocsBotAI.mount(Object.assign({}, e)).then(t).catch(r)}),(n=function e(t){return new Promise(e=>{if(document.querySelector(t))return e(document.querySelector(t));let r=new MutationObserver(n=>{if(document.querySelector(t))return e(document.querySelector(t)),r.disconnect()});r.observe(document.body,{childList:!0,subtree:!0})})})("#docsbotai-root"),]).then(()=>t()).catch(r)}),n.addEventListener("error",e=>{r(e.message)})})};
9+
DocsBotAI.init({ id: "iGrxSYKM42GJfYYLMX16/1JkGxSdnjkCj8KfeJbfV" });
10+
}, []);
11+
12+
return <>{children}</>;
13+
}

0 commit comments

Comments
 (0)