-
-
Notifications
You must be signed in to change notification settings - Fork 31.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
[docs-infra] Improve product mapping #37729
[docs-infra] Improve product mapping #37729
Conversation
Co-authored-by: Lukas <llukas.tyla@gmail.com> Signed-off-by: Olivier Tassinari <olivier.tassinari@gmail.com>
{ | ||
pathname: '/getting-started', | ||
icon: standardNavIcons.DescriptionIcon, | ||
children: [ | ||
{ pathname: '/getting-started/installation' }, | ||
{ pathname: '/getting-started/usage' }, | ||
{ pathname: '/getting-started/example-projects' }, | ||
{ pathname: '/getting-started/templates' }, | ||
{ pathname: '/getting-started/learn', title: 'Learning resources' }, | ||
{ pathname: '/getting-started/faq', title: 'FAQs' }, | ||
{ pathname: '/getting-started/supported-components' }, | ||
{ pathname: '/getting-started/supported-platforms' }, | ||
{ pathname: '/getting-started/support' }, | ||
], | ||
}, |
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.
Legacy, dead code
if (firstFolder === 'x') { | ||
productCategoryId = 'x'; | ||
productId = `x-${asPathWithoutLang.replace('/x/react-', '').replace(/\/.*/, '')}`; | ||
} | ||
|
||
if (asPathWithoutLang === '/versions/') { | ||
productId = null; | ||
// No match, give up on it. | ||
if (productId === 'x-') { | ||
productId = 'null'; | ||
} | ||
} |
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.
With the changes in this PR, we could in theory move this logic to http://github.com/mui/mui-x. To complement #9451. But one step at a time. This is made possible by no longer relying on getProductInfoFromUrl to label the Algolia search results.
@@ -85,7 +85,7 @@ const products = [ | |||
]; | |||
|
|||
export default function MuiProductSelector() { | |||
const { productId } = React.useContext(PageContext); | |||
const pageContext = React.useContext(PageContext); |
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.
So much easier for large scale code refactoring.
// Extra | ||
'productId', | ||
'productCategoryId', | ||
], |
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.
In Algolia Crawler, we get these values like this:
{
productId: $('meta[name="mui:productId"]').attr("content"),
productCategoryId: $('meta[name="mui:productCategoryId"]').attr("content"),
}
May want to incorporate the edge cases in https://github.com/mui/material-ui/pull/37721/files and close that one |
@Janpot Ah yes, great. I have updated this PR. |
This is a continuation of #37593, to be able to segment the traffic on GA4 between products, it fixes bugs at the same time.
product
->productId
to make it easier to navigate the codebase, better be clear as well.productId
stored in Algolia for the matching, rather than trying to re-compute the value from the pathname, this is wrong.getProductInfoFromUrl()
to be simpler a step toward the futureThe next steps would be:
getProductInfoFromUrl()
is hybrid, it feels like a leaky abstractionproductId
override the logic ofgetProductInfoFromUrl()
. There are cases when the URL structure is not straightforward.useDemoData()
has its own product id logic, this duplication is wrong. it should rely on thePageContext
, no reasons to be different.