File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed
Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ ( function ( ) {
2+ function initChefAi ( ) {
3+ const PUBLIC_API_KEY =
4+ "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiI2NWQxNWI0YTUyNTcyZmMzMDI2ODg1OTgiLCJpYXQiOjE3MDgyMTkyMTAsImV4cCI6MjAyMzc5NTIxMH0.kjO3jaiDucVtCmF-665MVeRBd-VBm5MYYvwrzoIfVyQ" ;
5+
6+ let cookbookContainer = document . getElementById ( "__cookbook" ) ;
7+ if ( ! cookbookContainer ) {
8+ cookbookContainer = document . createElement ( "div" ) ;
9+ cookbookContainer . id = "__cookbook" ;
10+ cookbookContainer . dataset . apiKey = PUBLIC_API_KEY ;
11+ document . body . appendChild ( cookbookContainer ) ;
12+ }
13+
14+ let cookbookScript = document . getElementById ( "__cookbook-script" ) ;
15+ if ( ! cookbookScript ) {
16+ cookbookScript = document . createElement ( "script" ) ;
17+ cookbookScript . id = "__cookbook-script" ;
18+ cookbookScript . src =
19+ "https://cdn.jsdelivr.net/npm/@cookbookdev/docsbot/dist/standalone/index.cjs.js" ;
20+ cookbookScript . async = true ;
21+ document . head . appendChild ( cookbookScript ) ;
22+ }
23+
24+ const keyPressPropagationBlocker = function ( e ) {
25+ e . stopPropagation ( ) ;
26+ } ;
27+
28+ document . addEventListener ( "cookbook:modal:state:change" , function ( e ) {
29+ const isOpen = e . detail . isOpen ;
30+ if ( isOpen ) {
31+ document . body . addEventListener ( "keydown" , keyPressPropagationBlocker , {
32+ capture : true ,
33+ } ) ;
34+ } else {
35+ document . body . removeEventListener (
36+ "keydown" ,
37+ keyPressPropagationBlocker ,
38+ { capture : true }
39+ ) ;
40+ }
41+ } ) ;
42+ }
43+
44+ if ( document . readyState === "complete" ) {
45+ initChefAi ( ) ;
46+ } else {
47+ window . addEventListener ( "load" , initChefAi ) ;
48+ }
49+ } ) ( ) ;
Original file line number Diff line number Diff line change @@ -618,6 +618,7 @@ validation:
618618 anchors : warn
619619
620620extra_javascript :
621+ - _site_essentials/js/init_chef_ai.js
621622 - _site_essentials/js/mathjax.js
622623 - https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0
623624 - https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js
You can’t perform that action at this time.
0 commit comments