@logicflow/dumi-theme-simple
Version:
Simple website theme based on dumi2.
61 lines (60 loc) • 1.99 kB
JavaScript
import React from 'react';
import { useIntl } from 'dumi';
import { InboxOutlined } from '@ant-design/icons';
import styles from "./SearchResult.module.less";
import { jsx as _jsx } from "react/jsx-runtime";
import { Fragment as _Fragment } from "react/jsx-runtime";
import { jsxs as _jsxs } from "react/jsx-runtime";
var getHighlightInfo = function getHighlightInfo(textSegments) {
return /*#__PURE__*/_jsx(_Fragment, {
children: textSegments.map(function (segment) {
return /*#__PURE__*/_jsx("span", {
className: "".concat(styles.segment, " ").concat(segment.highlighted ? styles.highlighted : ''),
children: segment.text
});
})
});
};
/**
* 展示搜索结果
* @returns
*/
export var SearchResult = function SearchResult(_ref) {
var results = _ref.results;
var intl = useIntl();
return /*#__PURE__*/_jsx("div", {
className: styles.searchResult,
children: results !== null && results !== void 0 && results.length ? results.map(function (r) {
return /*#__PURE__*/_jsxs("div", {
className: styles.item,
children: [/*#__PURE__*/_jsx("div", {
className: styles.subject,
children: r.subject
}), /*#__PURE__*/_jsx("div", {
className: styles.br
}), /*#__PURE__*/_jsxs("a", {
className: styles.result,
href: r.link,
children: [/*#__PURE__*/_jsx("div", {
className: styles.title,
children: getHighlightInfo(r.tilte)
}), /*#__PURE__*/_jsx("div", {
className: styles.description,
children: getHighlightInfo(r.description)
})]
})]
});
}) : /*#__PURE__*/_jsxs("div", {
className: styles.empty,
children: [/*#__PURE__*/_jsx(InboxOutlined, {
style: {
fontSize: 20
}
}), /*#__PURE__*/_jsx("div", {
children: intl.formatMessage({
id: '没有找到查询结果'
})
})]
})
});
};