Skip to content

Commit 2679d9a

Browse files
authored
redeploy AI assistant for traefikee documentation
1 parent cf8e76c commit 2679d9a

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"web-vitals": "^2.1.0"
1818
},
1919
"scripts": {
20-
"start": "react-scripts start",
20+
"start": "set PORT=8000 && react-scripts start",
2121
"build": "react-scripts build",
2222
"gen-assets": "rimraf static-assets && mkdir -p static-assets && cp build/static/js/*.js static-assets/main-v1.js",
2323
"test": "react-scripts test",

src/components/nav/Header.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Link from 'components/Link'
66
import SkipLink from 'components/Link/Skip'
77
import MainNav from 'components/nav/MainNav'
88
import DrawerNav from 'components/nav/DrawerNav'
9+
import useDocWhizzScript from './useDocWhizzScript'
910

1011
const Nav = styled(FaencyNav)`
1112
position: fixed;
@@ -120,6 +121,7 @@ const Header = ({ product }: { product?: string }) => {
120121
const [isDrawerOpen, setIsDrawerOpen] = useState(false)
121122
const [isHeaderScrolled, setHeaderScrolled] = useState(false)
122123

124+
useDocWhizzScript()
123125
const demoLink = useMemo(() => {
124126
if (product === 'hub') return 'https://info.traefik.io/traefik-hub-signup'
125127

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { useEffect, useMemo } from 'react'
2+
3+
const WHITELISTED_HOSTNAME = ['localhost', 'doc.traefik.io']
4+
5+
const useDocWhizzScript = () => {
6+
const { pathname, hostname } = window.location
7+
const product = pathname.split('/')[1]
8+
9+
const clientId = useMemo(() => {
10+
if (WHITELISTED_HOSTNAME.includes(hostname)) {
11+
// if (product === 'traefik') return '65e8267d7714e3b11a5ce139'
12+
if (product === 'traefik-enterprise') return '65f0e20984bd4dfcfe7e58a6'
13+
14+
return null
15+
}
16+
return null
17+
}, [hostname, product])
18+
19+
useEffect(() => {
20+
if (!!clientId) {
21+
const t = document.createElement('script')
22+
t.setAttribute('data-id', 'docwhizz-script')
23+
t.setAttribute('data-client', clientId)
24+
t.crossOrigin = 'anonymous'
25+
t.src = 'https://widget.docwhizz.com/index.js'
26+
t.type = 'module'
27+
document.head.appendChild(t)
28+
29+
return () => {
30+
document.head.removeChild(t)
31+
}
32+
}
33+
}, [clientId])
34+
}
35+
36+
export default useDocWhizzScript

0 commit comments

Comments
 (0)