-
-
Notifications
You must be signed in to change notification settings - Fork 8.7k
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
refactor: move blog theme component type defs to theme-classic #6175
Conversation
✔️ [V2] 🔨 Explore the source changes: c4b02ad 🔍 Inspect the deploy log: https://app.netlify.com/sites/docusaurus-2/deploys/61c7e5d884a53900078c9453 😎 Browse the preview: https://deploy-preview-6175--docusaurus-2.netlify.app |
⚡️ Lighthouse report for the changes in this PR:
Lighthouse ran on https://deploy-preview-6175--docusaurus-2.netlify.app/ |
Size Change: 0 B Total Size: 662 kB ℹ️ View Unchanged
|
A theme that creates a page with a component Our TS setup is messy, it's hard to see all the potential issues we have. Maybe we should create a separate issue to discuss current problems and find a methodology to know exactly where a type should live? Currently there doesn't seem to be a strong consensus 😅 |
No; the blog plugin doesn't make the components or create the pages. It merely passes the props down to the client. The What are moved are the theme component aliases. Imagine this: |
Somehow it does It it calls The theme component has to implement the TS contract that the content plugin defines. The content plugin is the owner of that contract.
I agree on this. However, it's not true for all those components you moved, such as
It depends 😅
Theoretically I agree for third-party themes, but in our case the goal is to really have a 1-1 mapping between classic/tailwind components IMHO. Eventually, we could even adopt a React-Native like convention, which basically choose the right implementation at build time:
|
The plugin doesn't demand What |
My rationale for keeping at least prop types in the plugin is that I'd like props to be typed on the content side too. For example: addRoute({
component: "@theme/XYZ",
props: {age: 42} // props should be type-checked here
) We don't have this in place for now but it's something I'd like to have in the future (both a new "props" API + a way to typechecked modules created with Now for |
After some pondering, I do think it's valuable to put the theme aliases that the blog plugin expects within the plugin's typedefs, as a contract. However, the other theme-classic specific types should still be moved. Because of the number of conflicts I'll open a new one later |
Motivation
It shouldn't be set up that way because these components are actually exposed by theme-classic and we can't ensure that other themes implement the same components. Also related to #6157 because PnP can't find
content-blog
types.Have you read the Contributing Guidelines on pull requests?
Yes