Doc.tsx 857 B

1234567891011121314151617181920212223242526272829303132333435
  1. 'use client'
  2. import { type FC, useEffect } from 'react'
  3. import { useContext } from 'use-context-selector'
  4. import TemplateEn from './template/template.en.mdx'
  5. import TemplateZh from './template/template.zh.mdx'
  6. import I18n from '@/context/i18n'
  7. import { LanguagesSupported } from '@/i18n/language'
  8. type DocProps = {
  9. apiBaseUrl: string
  10. }
  11. const Doc: FC<DocProps> = ({
  12. apiBaseUrl,
  13. }) => {
  14. const { locale } = useContext(I18n)
  15. useEffect(() => {
  16. const hash = location.hash
  17. if (hash)
  18. document.querySelector(hash)?.scrollIntoView()
  19. }, [])
  20. return (
  21. <article className='mx-1 px-4 sm:mx-12 pt-16 bg-white rounded-t-xl prose prose-xl'>
  22. {
  23. locale !== LanguagesSupported[1]
  24. ? <TemplateEn apiBaseUrl={apiBaseUrl} />
  25. : <TemplateZh apiBaseUrl={apiBaseUrl} />
  26. }
  27. </article>
  28. )
  29. }
  30. export default Doc