Skip to content
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

Merged
merged 7 commits into from
Feb 7, 2025
Merged

Load mdx images from UDR #2684

merged 7 commits into from
Feb 7, 2025

Conversation

RubenSandwich
Copy link
Collaborator

@RubenSandwich RubenSandwich commented Feb 5, 2025

πŸ”— 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 in config.flags.unified_docs_migrated_repos. Which currently only the HASHI_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 and ptfe-releases products. (e.g. terraform-plugins-* would match) So an added guard has been placed on that to make sure that remark-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:

Copy link

vercel bot commented Feb 5, 2025

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
dev-portal βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Feb 7, 2025 3:35pm

@RubenSandwich RubenSandwich self-assigned this Feb 5, 2025
Copy link

github-actions bot commented Feb 5, 2025

πŸ“¦ Next.js Bundle Analysis

This 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',
Copy link
Collaborator Author

@RubenSandwich RubenSandwich Feb 7, 2025

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(
Copy link
Collaborator Author

@RubenSandwich RubenSandwich Feb 7, 2025

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

@RubenSandwich RubenSandwich requested a review from a team February 7, 2025 17:56
Copy link
Contributor

@LeahMarieBush LeahMarieBush left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ‘ LGTM

@RubenSandwich RubenSandwich merged commit 0f63c8f into main Feb 7, 2025
9 checks passed
@RubenSandwich RubenSandwich deleted the load-mdx-imgs-from-udr branch February 7, 2025 18:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants