-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix: Fixing issue 309, which code block doesn't load all the time #326
Fix: Fixing issue 309, which code block doesn't load all the time #326
Conversation
adding prismjs to declared modules since it will be imported to solve the problem of code blocks loading
root layout adding language highlight imports to the root layout and starting the highlight from useEffect, it wil make the prism enable the highlight in the code blocks
I removed this because seems to me it is taking too much time to load all the components in the promise and not loading the highlight over the code block
Someone is attempting to deploy a commit to a Personal Account owned by @morethanmin on Vercel. @morethanmin first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I apologize for being late. Thank you for your patience!
No worries. Its me who need to thank you for creating this template. |
Fix: Fixing issue 309, which code block doesn't load all the time
Description
Note: Since I'm not a frontend dev and doesn't work with frontend and react there are many years, I might say that something maybe will be incorrect, so, be kind and tell me that I will solve.
Once you reload, the next times the code will be loaded.
Problem
When using the morethan-log I saw that sometimes code blocks are loaded and sometimes it wasn't loaded, and found the #309 issue warning about this started to try solve it.
I also saw that the problem doesn't occur in dev environment, but only when you run:
and in prod when you acces for the first time, to test, you can open some private windows and try access the site: https://morethan-log.vercel.app/apollo-gettings-started-mutate sometimes
Debug approach
First stuff I done was removing the prismjs imports in the notion renderer components to understand if it would work without them. So, they worked and I discovered the origin of the problem.
After this I was thinking for some days about could be happening and decided to try import the highlights out of the promise, I was thinking that the amount of JS files being loaded could be making the highlight lazy since when I was debugging the code appear first without highlight and right after in next breakpoint it disappear.
Solution
So I moved the imports to the root layout, installed prismjs (I previously checked it it was in the
package.json
and it wasn't there) and imported it according some internet tutorials.After all, I used prism to code:
And doing this, It was working all time, so if you can test and assure it, I would be very grateful.
Related tickets
#309
PR Checklist