import { useTranslation } from 'next-i18next' import { useContext } from 'react' import { useRouter } from 'next/router' import { ModalContext } from 'shared/context/modal-context.mjs' import { ModalWrapper } from 'shared/components/wrappers/modal.mjs' import { DynamicMdx } from 'shared/components/mdx/dynamic.mjs' import { PageLink } from 'shared/components/link.mjs' export const ns = ['docs'] /* * Lowercase and strip dots, then check if we have a definition for the term * If not, return false */ const asTerm = (term, jargon, lang) => { if (typeof term !== 'string') return false term = term.toLowerCase().split('.').join('') return jargon[lang]?.[term] ? term : false } /* * This is used for tags. * If it's a term, if it wraps a term in our terminology, it will make it clickable. * If not, it will merely return the em tag. * * Since terms are different between sites, this takes a jargon object as prop */ export const Term = ({ children, site, jargon = {} }) => { const { setModal } = useContext(ModalContext) const router = useRouter() const lang = router.locale const term = asTerm(children, jargon, lang) return term ? ( ) : ( {children} ) } // This takes a jargon object as input and returns a React component export const termList = (jargon, site) => ({ jaron, site }) => { const router = useRouter() const lang = router.locale const { t } = useTranslation(ns) return ( {Object.keys(jargon[lang]) .sort() .map((key, i) => ( ))}
{t('docs:term')} MDX {t('docs:docs')}
{key} {key}
) }