0

I'm trying to add a comment script to my blog running on Gatsby. Here is a part of post template :

  return (
    <Layout>
      <ArticleSEO article={article} authors={authors} location={location} />
      <ArticleHero article={article} authors={authors} />
      <ArticleAside contentHeight={contentHeight}>
        <Progress contentHeight={contentHeight} />
      </ArticleAside>
      <MobileControls>
        <ArticleControls />
      </MobileControls>
      <ArticleBody ref={contentSectionRef}>
        <MDXRenderer content={article.body}>
          <ArticleShare />
        </MDXRenderer>
      </ArticleBody>
      {mailchimp && article.subscription && <Subscription />}
      // I want to put <script> tag here
      {next.length > 0 && (
        <NextArticle narrow>
          <FooterNext>More articles from {name}</FooterNext>
          <ArticlesNext articles={next} />
          <FooterSpacer />
        </NextArticle>
      )}
    </Layout>
  );

I've read some article, some question and answer about this problem but I can't solve it. If you need full code, Click here. This is a example script that I want to add :

<script src="https://utteranc.es/client.js"
        repo="[ENTER REPO HERE]"
        issue-term="pathname"
        theme="github-light"
        crossorigin="anonymous"
        async>
</script>
quangthang
  • 38
  • 4
  • 1
    Have you tried creating the script tag in a `useEffect`, as suggested here: https://stackoverflow.com/questions/34424845/adding-script-tag-to-react-jsx ? – Gustav Feb 26 '20 at 08:24
  • 1
    Does this answer your question? [Adding script tag to React/JSX](https://stackoverflow.com/questions/34424845/adding-script-tag-to-react-jsx) – blaz Feb 26 '20 at 10:27

1 Answers1

0

Thank you, Gustav for the suggestion! I got it worked.

quangthang
  • 38
  • 4