dumi-theme-nocobase
Version:
<h1 align="center">dumi-theme-nocobase</h1>
15 lines (14 loc) • 779 B
JavaScript
import { history } from 'dumi';
export function getTargetLocalePath(_ref) {
var _ref$pathname = _ref.pathname,
pathname = _ref$pathname === void 0 ? history.location.pathname : _ref$pathname,
current = _ref.current,
target = _ref.target;
var clearPath = 'base' in current ? pathname.replace(current.base.replace(/\/$/, ''), '') : pathname.replace(new RegExp("".concat(current.suffix, "$")), '');
return 'base' in target ? "".concat(target.base).concat(clearPath).replace(/^\/\//, '/') : "".concat(clearPath).concat(target.suffix);
}
// 删除标题中的 HTML 标签
export var removeTitleCode = function removeTitleCode() {
var title = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
return title.replace(/<\w+>.*<\/\w+>/g, '');
};