-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
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] Fix GitHub source link redirection #43534
[docs-infra] Fix GitHub source link redirection #43534
Conversation
Netlify deploy previewhttps://deploy-preview-43534--material-ui.netlify.app/ Bundle size report |
@@ -107,14 +107,13 @@ export function ComponentLinkHeader(props: ComponentLinkHeaderProps) { | |||
size="small" | |||
variant="outlined" | |||
rel="nofollow" | |||
href={`${process.env.SOURCE_CODE_REPO}/blob/v${process.env.LIB_VERSION}/${headers.githubSource}`} | |||
href={`${process.env.SOURCE_CODE_REPO}/tree/v${process.env.LIB_VERSION}/${headers.githubSource}`} |
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.
href={`${process.env.SOURCE_CODE_REPO}/tree/v${process.env.LIB_VERSION}/${headers.githubSource}`} | |
href={`${process.env.SOURCE_CODE_REPO}/${/\.[a-z]{2,3}$/.test(headers.githubSource) ? 'blob' : 'tree'}/v${process.env.LIB_VERSION}/${headers.githubSource}`} |
Maybe I'm overengineering But with a regexp that check if the file ends with a dot plus 2 or 3 characters, you get a fix that work for all cases.
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 would imagine that on the API page we always link files and on the demo page folders, so it might be fine?
If we start to see regressions, yeah, I would add an exception here, it must be a folder.
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 component is not on the API page. It's the header of the demo. Technically, we could put files or folders in the markdown header
This is a quick follow-up on #43387.
This link creates a 301, which slows the user experience by about 200ms:
I keep forgetting about tree (folder) vs. blob (file) in the URL to link in GitHub.
Also, none of the other chips have target blank, I got confused that it didn't open in the same window. I removed it for consistency of behavior. We could discuss adding to all the chips as well, but I think it's a bit beyond this scope.
Preview: https://deploy-preview-43534--material-ui.netlify.app/material-ui/react-alert/