Skip to content

Commit

Permalink
Merge pull request #700 from CBIIT/BENTO-2193
Browse files Browse the repository at this point in the history
Frontend change for BENTO-2193.
  • Loading branch information
JoonLeeNIH authored Dec 7, 2022
2 parents c3313e4 + fb89ca5 commit d442c90
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/pages/search/components/cards/aboutCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,20 @@ import { Anchor } from 'bento-components';
const AboutCard = ({
searchText, data, classes, index,
}) => {
const results = data.text.replaceAll('$', '');
const results = data.text.map((result) => result.replaceAll('$', ''));

function getHighlightedText(text, highlight) {
// Split on highlight term and include term into parts, ignore case
const parts = text.split(new RegExp(`(${highlight})`, 'gi'));
const textString = text.reduce((searchResults, currentString, currentIndex) => {
let newResults = searchResults;
if (currentString.endsWith('.') || currentIndex >= text.length - 1) {
newResults = `${`${newResults} ${currentString}`}`;
} else {
newResults = `${`${newResults} ${currentString}`} ... `;
}
return newResults;
}, '');
const parts = textString.split(new RegExp(`(${highlight})`, 'gi'));
return (
<span>
{' '}
Expand Down

0 comments on commit d442c90

Please sign in to comment.