-
Notifications
You must be signed in to change notification settings - Fork 1k
fix(ColorModeImage): add baseURL support for public paths #6006
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
fix(ColorModeImage): add baseURL support for public paths #6006
Conversation
Fixes nuxt#5916 ColorModeImage component now properly adds the app.baseURL to public folder paths (starting with '/'), ensuring images work correctly in production with custom base URLs. This matches the behavior of other image components like ProseImg.
📝 WalkthroughWalkthroughThe ColorModeImage component was migrated to the Composition API and now computes refinedLight and refinedDark using Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Add useRuntimeConfig to the Vue stubs so the color-mode components build correctly in the non-Nuxt (Vue-only) build path. Also extract the base URL resolution logic into a shared helper function to reduce duplication between light and dark computed properties.
commit: |
benjamincanac
left a comment
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.
Thanks! 😊
Summary
Changes
ColorModeImage now properly prepends the app.baseURL to image paths starting with
/, ensuring images display correctly in production environments with custom base URLs. This implementation matches the existing behavior in the ProseImg component.Testing
Manual testing:
app.baseURLin nuxt.config.ts (e.g.,/base-url/)//(external URLs) are not affected