-
Notifications
You must be signed in to change notification settings - Fork 3
Make metadataBase apply to all pages, not just homepage #1677
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
Conversation
| @@ -1,3 +1,4 @@ | |||
| "use client" | |||
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.
These are all client components for now because they use runtime CSS-in-JS (Emotion) which depends on react useContext.
Marking them as use-client allows importing them into server components.
| @@ -1,5 +1,3 @@ | |||
| "use client" | |||
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.
layout.tsx needs to be a server component in order to define metadata
| searchParams, | ||
| title: `${channelDetails.title}`, | ||
| description: channelDetails.public_description, | ||
| image: channelDetails.configuration.logo, |
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.
This is unrelated to the other changes, but...
- we noticed the metadataBase issue because channel og:image were not working
og:imagecannot be an SVG, so without this change, they still won't work.
jonkafton
left a comment
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.
Works!.. in prod mode yarn build; yarn start;
Interesting and odd that it does not work in dev mode. You mentioned that's apparently the case on Slack, but didn't see that info while scanning the docs.
What are the relevant tickets?
Followup to #1671
Description (What does it do?)
This PR moves
metadadataBasefrom root page to root layout.Child pages load all their parent layouts (but not parent pages!) so the earlier positioning of metadataBase was only affecting the home page.
How can this be tested?
Despite what the docs say here, it seems like metadataBase does not work in local dev mode. So set
NODE_ENV=productionandNEXT_PUBLIC_ORIGIN=https://learn.mit.edu, then runyarn workspace main buildyarn workspace main startVisit your local production server and run
$$('meta').forEach(e => console.log(e.outerHTML))in the dev consoleog:imageurls beginning with learn.mit.edu