Created
December 11, 2016 15:22
-
-
Save thiagoa/274a165613d793edcbe1ec56debdf7d4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function replaceMention(text, mention) { | |
| const regexp = new RegExp(`^@${mention}\\b|(\\s)@${mention}\\b`, 'g'); | |
| const template = `$1<a href="#" data-js-mention>@${mention}</a>`; | |
| return text.replace(regexp, template); | |
| } | |
| export default function parseTweetMentions({ text, mentions }) { | |
| return mentions.reduce(replaceMention, text); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment