Skip to content

feat(blog): add error boundary & simplify mermaid rendering#11

Merged
CagesThrottleUs merged 8 commits intomainfrom
cages/fix-wrong-components-with-error-boundary
Dec 1, 2025
Merged

feat(blog): add error boundary & simplify mermaid rendering#11
CagesThrottleUs merged 8 commits intomainfrom
cages/fix-wrong-components-with-error-boundary

Conversation

@CagesThrottleUs
Copy link
Copy Markdown
Owner

Summary

This PR enhances the blog post rendering system by introducing comprehensive error handling through error boundaries and simplifying the Mermaid diagram integration by leveraging mermaid.live instead of client-side rendering.

Changes

Error Handling Improvements

  • Added BlogPostErrorBoundary component: A new error boundary specifically designed for blog post rendering with styled error messages and recovery options
  • Enhanced BlogPostLayout: Integrated error boundary to catch and display rendering errors gracefully with detailed error information
  • Improved useBlogPost hook: Added error handling with descriptive messages and proper JSX import support

Mermaid Integration Simplification

  • Refactored Mermaid component: Simplified from client-side rendering to using mermaid.live iframe embedding, reducing complexity and bundle size
  • Removed Mermaid configuration: Cleaned up unnecessary Mermaid configuration from constants file

Blog Service Optimization

  • Removed localStorage caching: Simplified blog service by removing localStorage caching logic, reducing code complexity

Dependency Management

  • Updated dependencies: Removed mermaid-related dependencies from package.json, reducing bundle size by ~1300 lines in package-lock.json
  • Version bump: Updated app version to 1.0.3

Impact

  • Bundle size reduction: Net reduction of 1,308 lines across the codebase
  • Improved error resilience: Blog posts with errors won't crash the entire application
  • Better user experience: Users see helpful error messages instead of blank screens
  • Simplified maintenance: Less complex code for diagram rendering and caching

Files Changed

  • 10 files modified
  • 349 insertions, 1657 deletions

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
…d styling

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
…ror display

- Added a new error display section in BlogPostLayout for better user feedback on MDX syntax errors.
- Introduced styling for error messages in BlogPostLayout.css.
- Integrated BlogPostErrorBoundary for improved error management during content rendering.

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
Add comprehensive test suites for previously untested components and
update existing tests to align with recent refactoring changes.

New test files created:
- BlogPostErrorBoundary: error boundary rendering and lifecycle tests
- CursorTracker: mouse event tracking and cleanup tests
- ReadingProgress: scroll progress and visibility tests

Updated existing test suites:
- BlogService: remove localStorage caching tests after cache removal
- BlogComponents: fix Mermaid tests for mermaid.live integration
- BlogPostLayout: add error UI navigation and edge case coverage
- BlogList: add edge cases for null index scenarios
- useBlogPost: add detailed error message handling tests

Test improvements:
- Fix CursorTracker tests by using proper MouseEvent instances instead
  of fireEvent on window (fixes target.closest TypeError)
- Update error boundary test to handle React's error formatting
- Achieve 100% line coverage on hooks and most components
- Overall coverage improved from 94.42% to 98.8%

Signed-off-by: CagesThrottleUs <manstein.felix@gmail.com>
@CagesThrottleUs CagesThrottleUs merged commit 9dc2e2b into main Dec 1, 2025
2 checks passed
@CagesThrottleUs CagesThrottleUs deleted the cages/fix-wrong-components-with-error-boundary branch December 1, 2025 06:08
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.

1 participant