Skip to content

Commit 6ff36d4

Browse files
committed
feat: apply highlightKeyword function to title and summary fields in DatasetCard; closes #60
1 parent c3a37fe commit 6ff36d4

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/components/SearchPage/DatasetCard.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
3131
parsedJson,
3232
index,
3333
onChipClick,
34-
keyword, //
34+
keyword,
3535
}) => {
3636
const { name, readme, modality, subj, info } = parsedJson.value;
3737
const datasetLink = `${RoutesEnum.DATABASES}/${dbname}/${dsname}`;
@@ -46,7 +46,7 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
4646
return text;
4747
}
4848

49-
const regex = new RegExp(`(${keyword})`, "gi");
49+
const regex = new RegExp(`(${keyword})`, "gi"); // for case-insensitive and global
5050
const parts = text.split(regex);
5151

5252
return (
@@ -96,8 +96,7 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
9696
to={datasetLink}
9797
target="_blank"
9898
>
99-
{name || "Untitled Dataset"}
100-
{/* {highlightKeyword(name || "Untitled Dataset", keyword)} */}
99+
{highlightKeyword(name || "Untitled Dataset", keyword)}
101100
</Typography>
102101
<Typography>
103102
Database: {dbname} &nbsp;&nbsp;|&nbsp;&nbsp; Dataset: {dsname}
@@ -121,7 +120,7 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
121120
key={idx}
122121
label={mod}
123122
variant="outlined"
124-
onClick={() => onChipClick("modality", mod)} //
123+
onClick={() => onChipClick("modality", mod)}
125124
sx={{
126125
"& .MuiChip-label": {
127126
paddingX: "6px",
@@ -159,8 +158,7 @@ const DatasetCard: React.FC<DatasetCardProps> = ({
159158
paragraph
160159
sx={{ textOverflow: "ellipsis" }}
161160
>
162-
<strong>Summary:</strong> {readme}
163-
{/* <strong>Summary:</strong> {highlightKeyword(readme, keyword)} */}
161+
<strong>Summary:</strong> {highlightKeyword(readme, keyword)}
164162
</Typography>
165163
)}
166164
</Stack>

0 commit comments

Comments
 (0)