@@ -9,6 +9,7 @@ import Header from './components/header'
9
9
import Footer from './components/footer'
10
10
11
11
import { Search } from './components/search'
12
+ import { Widget } from './components/widget'
12
13
import { ThemeSwitch } from './components/theme-switch'
13
14
14
15
import { getPageData } from './modules/sanity/utils'
@@ -101,40 +102,14 @@ const render = async () => {
101
102
} ,
102
103
)
103
104
104
- // Add Plug component directly to body
105
- if ( ! document . getElementById ( 'plug-platform' ) ) {
106
- const plugScript = document . createElement ( 'script' )
107
- plugScript . setAttribute ( 'type' , 'text/javascript' )
108
- plugScript . setAttribute ( 'id' , 'plug-platform' )
109
- plugScript . setAttribute ( 'src' , 'https://plug-platform.devrev.ai/static/plug.js' )
110
- document . body . appendChild ( plugScript )
111
-
112
- // Initialize Plug SDK after script loads
113
- plugScript . onload = ( ) => {
114
- if ( ( window as any ) . plugSDK ) {
115
- ( window as any ) . plugSDK ?. init ?.( {
116
- app_id : data ?. plug ?. id ,
117
- enable_session_recording : true ,
118
- } )
119
- ( window as any ) . plugSDK . onEvent ( ( payload : any ) => {
120
- switch ( payload . type ) {
121
- case "ON_PLUG_WIDGET_READY" :
122
- console . log ( "ON_PLUG_WIDGET_READY" ) ;
123
- ( window as any ) . plugSDK . initSearchAgent ( ) ;
124
- document . addEventListener ( "keydown" , function ( event ) {
125
- if ( event . key === "/" ) {
126
- console . log ( "KEYDOWN" ) ;
127
- event . preventDefault ( ) ;
128
- ( window as any ) . plugSDK . toggleSearchAgent ( ) ;
129
- }
130
- } ) ;
131
- break ;
132
- default :
133
- break ;
134
- }
135
- } ) ;
136
- }
137
- }
105
+ // Add Widget component to body
106
+ if ( ! document . getElementById ( 'widget-container' ) ) {
107
+ const widgetContainer = document . createElement ( 'div' )
108
+ widgetContainer . setAttribute ( 'id' , 'widget-container' )
109
+ document . body . appendChild ( widgetContainer )
110
+ ReactDOM . render ( React . createElement ( Widget , {
111
+ ...data . plug
112
+ } ) , widgetContainer )
138
113
}
139
114
}
140
115
0 commit comments