gatsby-starter-prismic
gatsby-starter-prismic copied to clipboard
Inline code highlight will cause failed during gatsby build
Hi,
I have an issue that when I was editing an article in prismic using inline code highlight, during the gatsby build
it will throw an error below:
Starting to fetch data from Prismic
Fetch Prismic data: 1298.650ms
ERROR #11321 PLUGIN
"gatsby-source-prismic" threw an error while running the sourceNodes lifecycle:
Cannot read property 'rest' of undefined
TypeError: Cannot read property 'rest' of undefined
- prism.js:414 Object.tokenize
[gatsby-starter-prismic]/[prismjs]/prism.js:414:22
- prism.js:280 Object.highlight
[gatsby-starter-prismic]/[prismjs]/prism.js:280:18
- htmlSerializer.js:39 htmlSerializer
/home/yliu/Desktop/gatsby-starter-prismic/src/gatsby/htmlSerializer.js:39:20
- prismic-dom.min.js:8 a
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87261
- prismic-dom.min.js:8
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87237
- Array.reduce
- prismic-dom.min.js:8 a
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87197
- prismic-dom.min.js:8
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87237
- Array.reduce
- prismic-dom.min.js:8 a
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87197
- prismic-dom.min.js:8 a
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87321
- prismic-dom.min.js:8
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87093
- Array.map
- prismic-dom.min.js:8 Object.e [as serialize]
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:8:87068
- prismic-dom.min.js:1 Object.asHtml
[gatsby-starter-prismic]/[prismic-dom]/dist/prismic-dom.min.js:1:4236
- normalize.js:62 normalizeRichTextField
[gatsby-starter-prismic]/[gatsby-source-prismic]/normalize.js:62:38
⠦ source and transform nodes
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I suspect in htmlSerializer.js
the const codeInline
should also include the different other program languages, not just text
.
After adding the language I need to highlight, the error can be solved.
Hi!
It's "kinda" working as intended as I only think that inline code should be used with the text
label. It doesn't need special syntax highlighting or labels as it just wraps the text with a classname to be able to style it.
I only intended the other labels to be used with the "preformatted" block (in the rich text editor) and the code slice.
A better error message or some gracefully switching to something else is a good idea, but I currently don't have time to implement it into this starter and rather wait a bit to put it into its own Gatsby theme when re-writing this starter.
Yes, I agree.
Better to mention this in Readme, since in the text slice, for the inline code, the rich text editor supports to label other programming languages than just text
.
Otherwise, the error is quite misleading.