@logicflow/dumi-theme-simple
Version:
Simple website theme based on dumi2.
38 lines • 1.11 kB
JavaScript
import React from 'react';
import classNames from 'classnames';
import { history, FormattedMessage } from 'dumi';
import styles from "./NavigatorBanner.module.less";
import { useScrollToTop } from "../hooks";
import { jsx as _jsx } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
export var NavigatorBanner = function NavigatorBanner(_ref) {
var post = _ref.post,
type = _ref.type;
if (!post) {
return /*#__PURE__*/_jsx("div", {
className: classNames(styles.button, styles.hidden)
});
}
var slug = post.slug,
title = post.title;
if (!slug || !title) {
return null;
}
function go() {
history.push(slug);
useScrollToTop();
}
return /*#__PURE__*/_jsxs("div", {
className: classNames(styles.button, styles[type]),
onClick: go,
children: [/*#__PURE__*/_jsx("div", {
className: styles.label,
children: /*#__PURE__*/_jsx(FormattedMessage, {
id: type === 'prev' ? '上一篇' : '下一篇'
})
}), /*#__PURE__*/_jsx("div", {
className: styles.title,
children: title
})]
});
};