fix(ColorModeImage): add baseURL support for public paths#6006
fix(ColorModeImage): add baseURL support for public paths#6006benjamincanac merged 5 commits intonuxt:v4from
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: |
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