@@ -5,7 +5,8 @@ import { useConfig } from 'nextra-theme-docs';
5
5
import { FeelbackYesNo , PRESET_LIKE_DISLIKE } from '@feelback/react' ;
6
6
import '@feelback/react/styles/feelback.css' ;
7
7
import { Search } from './components/Search' ;
8
- import { RiSparkling2Fill } from '@remixicon/react' ;
8
+ import { AskAIButton } from './components/AskAIButton' ;
9
+ import { useFeature } from '@growthbook/growthbook-react' ;
9
10
10
11
const config : DocsThemeConfig = {
11
12
logo : (
@@ -31,12 +32,7 @@ const config: DocsThemeConfig = {
31
32
component : Search
32
33
} ,
33
34
navbar : {
34
- extraContent : (
35
- < button id = 'custom-ask-ai-button' className = 'nx-flex nx-gap-2 nx-items-center nx-py-1.5 nx-px-3 nx-rounded-lg nx-text-sm nx-font-semibold' style = { { backgroundColor : '#FF0420' , color : 'white' , display : 'flex' , alignItems : 'center' , gap : '4px' } } >
36
- < span > Ask AI</ span >
37
- < RiSparkling2Fill size = { 14 } />
38
- </ button >
39
- )
35
+ extraContent : AskAIButton
40
36
} ,
41
37
docsRepositoryBase : 'https://github.com/ethereum-optimism/docs/blob/main/' ,
42
38
footer : {
@@ -121,6 +117,7 @@ const config: DocsThemeConfig = {
121
117
const { asPath, defaultLocale, locale } = useRouter ( ) ;
122
118
const { frontMatter } = useConfig ( ) ;
123
119
const url = 'https://docs.optimism.io' + ( defaultLocale === locale ? asPath : `/${ locale } ${ asPath } ` ) ;
120
+ const enableDocsAIWidget = useFeature ( 'enable_docs_ai_widget' ) . on ;
124
121
125
122
return (
126
123
< >
@@ -133,20 +130,23 @@ const config: DocsThemeConfig = {
133
130
< meta name = 'twitter:description' content = { frontMatter . description || 'Optimism Docs for developers' } />
134
131
< meta name = 'twitter:image' content = 'https://docs.optimism.io/logos/docs-header.png' />
135
132
< link rel = 'icon' href = '/img/icons/favicon.ico' type = 'image/x-icon' > </ link >
136
- < script
137
- async
138
- src = 'https://widget.kapa.ai/kapa-widget.bundle.js'
139
- data-website-id = { process . env . NEXT_PUBLIC_KAPA_WEBSITE_ID }
140
- data-project-name = 'OP Labs'
141
- data-project-color = '#FF0420'
142
- data-modal-title = 'Optimism Docs Assistant ✨'
143
- data-project-logo = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR8nhCmw7cu6jVQI01JFtMAV5tkTNLJXMSAOg& s '
144
- data-modal-example-questions = 'What is the OP Stack?, How do I get started with Supersim?, How do I create a SuperERC20 token?, How do I get faucet funds?'
145
- data-user-analytics-fingerprint-enabled = 'true'
146
- data-modal-override-open-id = 'custom-ask-ai-button'
147
- data-button-hide = 'true'
148
- data-max-tokens = '100'
149
- > </ script >
133
+ { enableDocsAIWidget && (
134
+ < script
135
+ async
136
+ src = 'https://widget.kapa.ai/kapa-widget.bundle.js'
137
+ data-website-id = { process . env . NEXT_PUBLIC_KAPA_WEBSITE_ID }
138
+ data-project-name = 'OP Labs'
139
+ data-project-color = '#FF0420'
140
+ data-modal-title = 'Optimism Docs Assistant ✨'
141
+ data-project-logo = 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR8nhCmw7cu6jVQI01JFtMAV5tkTNLJXMSAOg& s '
142
+ data-modal-example-questions = 'What is the OP Stack?, How do I get started with Supersim?, How do I create a SuperERC20 token?, How do I get faucet funds?'
143
+ data-user-analytics-fingerprint-enabled = 'true'
144
+ data-modal-override-open-id = 'custom-ask-ai-button'
145
+ data-modal-ask-ai-input-placeholder = 'Ask me a question about building on Optimism'
146
+ data-button-hide = 'true'
147
+ data-max-tokens = '100'
148
+ > </ script >
149
+ ) }
150
150
</ >
151
151
) ;
152
152
}
0 commit comments