Skip to content

Commit

Permalink
feat: AI assistant for traefikee and proxy documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
gndz07 authored Mar 15, 2024
1 parent fea4f5b commit f138787
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"web-vitals": "^2.1.0"
},
"scripts": {
"start": "react-scripts start",
"start": "set PORT=8000 && react-scripts start",
"build": "react-scripts build",
"gen-assets": "rimraf static-assets && mkdir -p static-assets && cp build/static/js/*.js static-assets/main-v1.js",
"test": "react-scripts test",
Expand Down
2 changes: 2 additions & 0 deletions src/components/nav/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Link from 'components/Link'
import SkipLink from 'components/Link/Skip'
import MainNav from 'components/nav/MainNav'
import DrawerNav from 'components/nav/DrawerNav'
import useDocWhizzScript from './useDocWhizzScript'

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

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

Expand Down
36 changes: 36 additions & 0 deletions src/components/nav/useDocWhizzScript.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { useEffect, useMemo } from 'react'

const WHITELISTED_HOSTNAME = ['localhost', 'doc.traefik.io']

const useDocWhizzScript = () => {
const { pathname, hostname } = window.location
const product = pathname.split('/')[1]

const clientId = useMemo(() => {
if (WHITELISTED_HOSTNAME.includes(hostname)) {
if (product === 'traefik') return '65e8267d7714e3b11a5ce139'
if (product === 'traefik-enterprise') return '65f0e20984bd4dfcfe7e58a6'

return null
}
return null
}, [hostname, product])

useEffect(() => {
if (!!clientId) {
const t = document.createElement('script')
t.setAttribute('data-id', 'docwhizz-script')
t.setAttribute('data-client', clientId)
t.crossOrigin = 'anonymous'
t.src = 'https://widget.docwhizz.com/index.js'
t.type = 'module'
document.head.appendChild(t)

return () => {
document.head.removeChild(t)
}
}
}, [clientId])
}

export default useDocWhizzScript

0 comments on commit f138787

Please sign in to comment.