-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TNO-2784: Stories on Press Gallery landing page are not written by Pr…
…ess Gallery members. (#2020) * Load Press Members in initial load. Filter Press Members by Press Member/Date Highlight Press Members in header, byline, body. * Add files after running make pack n=editor and make pack n=subscriber * publish tno-core 0.1.99
- Loading branch information
Showing
22 changed files
with
183 additions
and
43 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file renamed
BIN
+1.91 MB
...core-npm-0.1.98-74932298ce-76a0edb9a4.zip → ...core-npm-0.1.99-d5f586ac09-b4013a47bb.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file renamed
BIN
+1.91 MB
...core-npm-0.1.98-74932298ce-76a0edb9a4.zip → ...core-npm-0.1.99-d5f586ac09-b4013a47bb.zip
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
app/subscriber/src/components/content-list/utils/highlightTerms.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
export const highlightTerms = ( | ||
body: string, | ||
highlightedVals: string[], | ||
): (string | JSX.Element)[] => { | ||
const regex = new RegExp( | ||
`(${highlightedVals.map((term) => escapeRegExp(term)).join('|')})`, | ||
'gi', | ||
); | ||
|
||
// Function to escape special characters in a string for regex | ||
function escapeRegExp(str: string) { | ||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); | ||
} | ||
|
||
// Split the body into segments based on the regex | ||
const segments = body.split(regex); | ||
|
||
const result: (string | JSX.Element)[] = segments.map((segment, index) => { | ||
if (highlightedVals.some((term) => segment.toLowerCase().includes(term.toLowerCase()))) { | ||
return <b key={`highlighted_${index}`}>{segment}</b>; | ||
} else { | ||
return segment; | ||
} | ||
}); | ||
|
||
return result; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Oops, something went wrong.