import classNames from 'classnames'; import { history, useIntl } from 'dumi'; import React from 'react'; import { useScrollToTop } from '../hooks'; import styles from './NavigatorBanner.module.less'; export interface NavigatorBannerProps { post?: | { slug?: string; title?: string; } | undefined; type: 'prev' | 'next'; } export const NavigatorBanner: React.FC = ({ post, type }) => { const { formatMessage } = useIntl(); if (!post) { return
; } const { slug, title } = post; if (!slug || !title) { return null; } function go() { history.push(slug as string); useScrollToTop(); } return (
{formatMessage({ id: type === 'prev' ? '上一篇' : '下一篇' })}
{title}
); };