-
Notifications
You must be signed in to change notification settings - Fork 28
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
Load mdx images from UDR #2684
Load mdx images from UDR #2684
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
π¦ Next.js Bundle AnalysisThis analysis was generated by the next.js bundle analysis action π€ This PR introduced no changes to the javascript bundle π |
@@ -273,6 +273,7 @@ describe('RemoteContentLoader', () => { | |||
}) | |||
|
|||
expect(mockMdxContentHook).toHaveBeenCalledWith(expect.any(String), { | |||
product: 'waypoint', |
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.
Needed as we are now injecting the product
into the "content loaders"
@@ -78,6 +78,9 @@ export function getDeployPreviewLoader({ | |||
if ( | |||
currentRootDocsPath.productSlugForLoader?.match( | |||
/^(terraform|ptfe-releases)/i | |||
) && | |||
!__config.flags?.unified_docs_migrated_repos?.find( |
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.
Added to prevent remark-rewrite-assets
from running twice for terraform products
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.
π LGTM
π Relevant links
ποΈ What
This PR modifies MDX image loading to load from the UDR asset API. It does this by updating and injecting the
remark-rewrite-assets.ts
remark plugin to rewrite the MDX img URLs when an product is inconfig.flags.unified_docs_migrated_repos
. Which currently only theHASHI_ENV=unified-docs-sandbox
has those flags set.Before this only use case of remark-rewrite-assets remark plugin was in rewriting the MDX imgs of URLS for any
terraform
andptfe-releases
products. (e.g.terraform-plugins-*
would match) So an added guard has been placed on that to make sure thatremark-rewrite-assets
does not run twice in those situations.π§ͺ Testing
This branch has special env vars injected into it so that it loads content from UDR. So it can be tested by visiting the following links:
A UDR product loads images from the UDR asset API
A NON UDR product loads images from the normal asset API
/_next/image?url=https%3A%2F%2Fcontent.hashicorp.com%2Fapi%2Fassets%3Fproduct%3Dnomad%26version%3Drefs%252Fheads%252Fstable-website%26asset%3Dwebsite%252Fpublic%252Fimg%252Fnomad-architecture-region.png%26width%3D1920%26height%3D852&w=3840&q=75&dpl=dpl_8W7uyq4JfqA3fDjL1z9LF9hFo1FA