Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Link Twitter handles in the testimonial section #29

Closed
2 tasks done
bdougie opened this issue Jul 6, 2022 · 14 comments · Fixed by #157
Closed
2 tasks done

Feature: Link Twitter handles in the testimonial section #29

bdougie opened this issue Jul 6, 2022 · 14 comments · Fixed by #157

Comments

@bdougie
Copy link
Member

bdougie commented Jul 6, 2022

Type of feature

🍕 Feature

Current behavior

When viewing testimonials, any @ mentioned uses are not linkable.
Screen Shot 2022-07-06 at 2 45 26 PM

Suggested solution

Make them linkable through either a service or sanitizing through markdown.

Additional context

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Contributing Docs

  • I agree to follow this project's Contribution Docs
@shamimbinnur
Copy link
Contributor

@bdougie Can I take it over?

@takanome-dev
Copy link

@bdougie I used some transformation to replace twitter handles into links :

const regex = /(?<=@)\w+/g

  const transformParagraph = (paragraph: string) => {
    const words = paragraph.split(' ')
    const transformedWords = words.map((word) => {
      if (word.match(regex)) {
        return `<a href="https://twitter.com/${word.replace(
          '@',
          ''
        )}" target="_blank" rel="noopener noreferrer">${word}</a>`
      }
      return word
    })
    return transformedWords.join(' ')
  }

After that I tried to use some libraries like markdown-it, marked and others but they transform the string to html or markdown and it showed up as a string in the browser, so I passed the transformParagraph to the p tag through dangerouslySetInnerHTML attribute and here is the result:

opensauced-landing

What are your thoughts about it?

@SimranjitKaurMaan
Copy link

SimranjitKaurMaan commented Jan 14, 2023

@takanome-dev Another possible solution could be to show the string content in p tag and show the twitter handle in a tag. This can be done by parsing the entire testimonial content recursively and parse the string content and twitter handle separately. Parse the @content as a tag whereas parse without @ as p tag. Am i clear enough to explain the approach?

@takanome-dev
Copy link

Sorry, I'm not sure I understand what you mean.
How about taking this over and open a pr?

@SimranjitKaurMaan
Copy link

No worries. Let me open a PR for it.

.take

@wasimapinjari
Copy link
Contributor

.take

@github-actions
Copy link
Contributor

Thanks for being interested in this issue. It looks like this ticket is already assigned to a contributor. Please communicate with the assigned contributor to confirm the status of the issue.

@wasimapinjari
Copy link
Contributor

wasimapinjari commented Jul 29, 2023

I fixed it!

Screenshot (214)

@wasimapinjari
Copy link
Contributor

wasimapinjari commented Jul 29, 2023

But before that, when I forked the repo and clicked on this file there was an issue already (this is not related to my code):

This is how I set up the project:

npm i
npm run dev

After seeing the error I did the following:

npm run lint
npm ci
npm run dev

It seems like there is some conflict with TypeScript.

My final attempt at solving:

npm i framer-motion
npm run dev

But the error remains:

Screenshot (203)

@a0m0rajab
Copy link

Thank you for your work! @wasimapinjari can you open a PR to check it from there?
Plus, you have a great solution! when I first looked at this I thought about RegEx but your solution is simpler.

@wasimapinjari
Copy link
Contributor

@a0m0rajab do you mind fixing this?

Screenshot (223)

@a0m0rajab
Copy link

I do not think that this problem would prevent you from opening your PR, but to fix it you can do the next:
take out the

const transition = { duration: 0.5, delay: 0.2, ease: 'easeInOut', type: 'spring', stiffness: 50 };
  return (
    <motion.div
      ref={refCard}
      initial={{ opacity: 0, y: cardInView ? 100 : 0 }}
      animate={{ opacity: cardInView ? 1 : 0 , y: cardInView ? 0 : 100 }}
      transition={transition}
      >

or use as from TS:

transition={{ duration: 0.5, delay: 0.2, ease: 'easeInOut', type: 'spring', stiffness: 50} as Transition}

@wasimapinjari
Copy link
Contributor

@a0m0rajab Thanks, this will surely help me in the future if I encounter this type of error next time. 😀

@a0m0rajab
Copy link

You are welcome! it's great to see your contributions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants