import Link from 'next/link' import { useRouter } from 'next/router' import { Admonition } from 'ui' import { useMenuActiveRefId } from '~/hooks/useMenuState' import { ICommonSection } from './Reference.types' export interface OldVersionAlertProps { sections: ICommonSection[] } const OldVersionAlert = ({ sections }: OldVersionAlertProps) => { const router = useRouter() const activeRefId = useMenuActiveRefId() const activeSection = sections.find(({ id }) => id === activeRefId) // Remove the version number from URL to get the latest const latestVersionUrl = router.asPath .split('/') .slice(0, -2) .concat(activeSection ? [activeSection.slug] : []) .join('/') return (
You're viewing an older version of this library.
Switch to the latest .
) } export default OldVersionAlert