question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"SyntaxError: Unexpected token ." when using custom gatsby-transformer-contentful-richtext config

See original GitHub issue

I added the following to gatsby-config.js, per the package readme.

However, when I run gatsby develop I get an unexpected token . error on the require statement.

Is this a valid require syntax?

const { BLOCKS.EMBEDDED_ENTRY } = require ('@contentful/rich-text-types')

plugins: [
  {
   resolve: `gatsby-transformer-contentful-richtext`,
   options: {
      renderOptions: {
        /*
        * Defines custom html string for each node type like heading, embedded entries etc..
        */
        renderNode: {
          // Example
          [BLOCKS.EMBEDDED_ENTRY]: (node) => `<div class='custom-entry'>${customComponentRenderer(node)}</div>`
        },
        /*
        * Defines custom html string for each mark type like bold, italic etc..
        */
        renderMark: {
          // Example
          [MARKS.BOLD]: text => `<custom-bold>${text}<custom-bold>`
        }
      }
   }
  }
]

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
aofoltscommented, Dec 11, 2018

@Khaledgarbaya No worries! Thanks for clarifying about the readme. I was thinking…is this some new require syntax or what, haha?

I got the sandbox example working, and then I realized I was using INLINES.EMBEDDED_ENTRY instead of INLINES.ENTRY_HYPERLINK, which is why I wasn’t seeing anything showing up.

Anyway, great work on the Gatsby plugin—makes things a million times easier, and rich text is absolutely brilliant! 💯

1reaction
Khaledgarbayacommented, Dec 11, 2018

Hey @aofolts, My apologies there was a silly mistake in the README. I prepared a sample project that works with custom renderers here is the code sandbox link

Cheers, Khaled

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
node.js - How to solve error "SyntaxError: Unexpected token '?'"
This will install and use the latest Node.js v14 (14.17.4). If u want to use a different version, change nvm install 14 to...
Read more >
SyntaxError: Unexpected token is thrown while combining the ...
SyntaxError : Unexpected token is thrown while combining the custom ... or turn off loading // the plugins file with the 'pluginsFile' configuration...
Read more >
SyntaxError: Unexpected token in JavaScript | bobbyhadz
The "Uncaught SyntaxError: Unexpected token" occurs for multiple reasons: Having a <script /> tag that points to an HTML file instead of a...
Read more >
SyntaxError: unexpected token - SharePoint Stack Exchange
If you want to accumulate the results of your loop, you should declare a variable outside of it and then use inside the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found