Pre-rendered seo#46
Conversation
hsab
left a comment
There was a problem hiding this comment.
Some comments and explanations on the code
| import paper from "paper"; | ||
|
|
||
| import style from "./style.module.scss"; | ||
| import './style-blobs.css'; |
There was a problem hiding this comment.
This managed to fix the styling when the user enters the homepage from and external link or by typing in the address bar.
There was a problem hiding this comment.
very strange that this would happen here and not break the other components that use css modules.
There was a problem hiding this comment.
Yeah exactly my thought.
There was a problem hiding this comment.
I can't reproduce this. I renamed style-blobs.css to style.module.css, removed blobs- from the style names. and then
import {
wrapper,
popover,
} from './style.module.css';
in the index.js and then className={wrapper} etc and the correct styles are being applied. It does appear as style_wrapper__1dMCn but that's just the generated name from the css modules. The content of the class is accurate.
There was a problem hiding this comment.
or was this only happening on Production? Just realized that
There was a problem hiding this comment.
This is happening in production. Also I have temporarily fixed it by removing the class assignment on PageHeader. Have a look at the last commit when you can 7767417
| return ( | ||
| <div | ||
| className={style.wrapper} | ||
| className='blobs-wrapper' |
There was a problem hiding this comment.
Again fixing styling when entering the homepage from an external link or by typing in the address bar. #46 (comment)
| className='blobs-wrapper' | ||
| ref={wrapperEl} | ||
| style={collapsed ? {} : { width: parentWidth, height: parentHeight }} | ||
| // style={collapsed ? {} : { width: parentWidth, height: parentHeight }} |
| </div> | ||
| )} | ||
| <div className={style.popover} style={popoverStyle}> | ||
| <div className='blobs-popover' style={popoverStyle}> |
| @@ -1,22 +1,22 @@ | |||
| .wrapper { | |||
| .blobs-wrapper { | |||
There was a problem hiding this comment.
Changing from SASS to pure CSS #46 (comment)
There was a problem hiding this comment.
did you try this with the modules in place? I'm wondering if it was actually sass that was breaking it.
There was a problem hiding this comment.
I'm gonna give it a try and report back.
There was a problem hiding this comment.
No success :(
I found:
- Reload applies adds CSS Classes to a div that shouldn't have it stereobooster/react-snap#437 which seems to be exactly our issue as "this only occurs when running the production build".
- weird element placement behavior stereobooster/react-snap#214 (comment)
- Dynamic CSS theme and react-snap stereobooster/react-snap#432
- material-ui / jss / dynamic imports stereobooster/react-snap#99 (
window.snapSaveState?)
There's also the following in my console during dev preview:
Warning: Expected server HTML to contain a matching <div> in <div>.
in div (at App/index.js:10)
in Router (created by BrowserRouter)
in BrowserRouter (at App/index.js:9)
in Unknown (at src/index.js:17)
in StrictMode (at src/index.js:16)
console.<computed> @ index.js:1
Wondering if this has to do with that lingering "," but figuring it out is way over my head and my react knowledge.
There was a problem hiding this comment.
ok. i can take a look after the lecture tonight
There was a problem hiding this comment.
Hey managed to narrow down the issue to PageHeader component's outermost div. Removing the className on this element fixes the problem. But no matter how hard I tried to add the class back, be it through pure css, having the css in the public folder and linking in html, sass, etc, it kept messing up the bg titles after returning to homepage from an artist page. I hope this helps.
| category, | ||
| tags, | ||
| twitter, | ||
| image: image ? image.images[image.images.length - 1].path : 'FALLBACKIMAGE' |
There was a problem hiding this comment.
FALLBACKIMAGE needs to be changed to default image later on.
| return ( | ||
| <Route path={`/${slug}`} key={slug}> | ||
| <Comp /> | ||
| <Comp config={config.artists[i]}/> |
There was a problem hiding this comment.
Passing the config data to the artist component to automatically infer the path and title.
There was a problem hiding this comment.
i'm not sure if this will do what is intended. Lazy is used to code split the bundle, so each artist has their own js file instead of loading them all at once. Or is this just to pass the SEO metadata?
There was a problem hiding this comment.
This is to just pass the SEO data from the config to the component. I'm not sure if what I'm doing is right. But the styling issue existed even when I had the metadata hardcoded with this file unmodified.
There was a problem hiding this comment.
weird. lets see how removing sass goes and then i can poke around if you want. If the site is going to be static though you could remove the lazy stuff entirely since it won't help too much.
There was a problem hiding this comment.
It seems like snap supports webpack chunks. Is this what Lazy uses? Based on what I know snap is only semi-static and still depends on being hydrated, generating the most basic html needed for pre-rendering. Wonder if chunks help in this regard. Also glancing over the generated artist htmls I see a lot of xxxxx.chunk.js
| font-family: sans-serif; | ||
| font-weight: 700; | ||
| line-height: initial; | ||
| margin-top: 50vh; |
There was a problem hiding this comment.
Again fixing styling when entering the homepage from and external link or by typing in the address bar. Translation is to accommodate centering in the absence of
style={collapsed ? {} : { width: parentWidth, height: parentHeight }}
#46 (comment)
… but this was my first stab and it is slightly cleaner) adds blob style modules back blobfield checks for collapsed state via useLocation rather than route callback reorder blobfield to be before switch adds wrapper class back to header removed lazy and suspense (this gave me about 20 more FPS on the blobs!)
|
Ok just pushed a bunch and i believe it is fixed. It seemed to be something up with the router. So i shuffled some things there, the main fix was putting blob field at the top and adding useLocation to set the value of collapsed vs a route with a match callback. Seems to all be working now although i can't say 100% that i understand why, which is frustrating. As a side effect, i removed the code splitting to see if that was causing trouble and got a remarkable increase in speed from that? Possibly some heisenbuggy non-sense, but it was reproducible, and the load trade off is minimal since the chunks are actually much smaller than i anticipated. No luck on that freaking comma, need to not be on the computer for a while but i'll look again later tonight or more likely in the monring. |
|
It's always the little things lol 05cb69e#diff-1fdf421c05c1140f6d71444ea2b27638R17 |
|
erp, my bad with the single quotes. now I know! |
|
Oh no i was linking to that one line #17, there was a comma in there. The single quotes change i think was hirad and is just personal preference. |
|
ohh haha I didn't really know how single vs double quotes could result in a comma but the internet never ceases to amaze me |
oh my. that was a leftover from the argument separator to |
…auses some issue when directly visiting the homepage
|
did y'all ever figure out the style issue? if it's only happening on production it probably has something to do with |
|
@blerchin @brysonian This looks good to be merged into master. Also fixed the seo/smo stuff for homepage in the last commit |
Fascinating. With code splitting webpack has to duplicate a lot of dependencies so that may have been a source of slowness. Also with static imports it can do some additional optimizations, tree-shaking and stuff. So that might be speeding things up and making the single bundle smaller than expected. |
|
re: classnames, i was something in router combined with the hydration. but to find the exact problem would require diving into the guts of those libs |
|
@hsab still getting up to speed with this. I will take a quick look to try to familiarize myself. But excited to have this working! We may need to remove |
|
@blerchin |
|
Also if this of any help, you can see the redirections: |
|
weird stuff. Well, it's still working without _redirects. In any case, it's good not to depend on proprietary config stuff. |
|
I looked over the diff, and while I don't have a lot of context on this it all LGTM. |
If you're going to approve, let me update the link to our master preview. |
|
@hsab when you feel it's ready, you can approve and I'll merge 😏 |
|
@blerchin Should be good now. I can't approve since I'm the PR author. |
|
@hsab oh, I didn't realize that's how it works. I'll approve in that case |







Preview Production Build
After a bit of testing with #45 I managed to get great results.
Decided to branch off of master again because I was just fiddling with code in #45. Wanted to make sure that the changes I've made are meaningful and appropriate. This PR is to be considered clean but there are still 2 issues left that I'm trying to solve.
Create React App: Title and Meta Tags
Create React App: Pre-Rendering into Static HTML Files
react-snap
react-helmet
SEO Recipe
react-snap Recipes
For production we just need to update this line to our final domain:
dma-20-mfa-show/src/Components/Seo/index.js
Line 7 in 25c71e8
Performance Metrics
Issues:
Incorrect class assignment to the blobs wrapper
style_container__##XXwhere it should beblobs-wrapperLingering
","at the end ofrootdiv