"SyntaxError: Unexpected token ." when using custom gatsby-transformer-contentful-richtext config
See original GitHub issueI 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:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@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 ofINLINES.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! 💯
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