Mermaid Auto-Detection Migration Guide¶
What Changed? π―¶
The zer0-mistakes theme now automatically detects Mermaid diagrams. You no longer need mermaid: true in front matter!
Before (Manual Configuration)¶
After (Auto-Detection)¶
Action Required¶
None! Your existing posts still work (backwards compatible).
The theme automatically: - β Detects ```mermaid code blocks in your content - β Loads Mermaid.js library on-demand - β Renders diagrams with optimized settings - β Maintains all existing functionality
Optional Cleanup¶
You can remove mermaid: true from front matter to clean up your posts:
Benefits of Cleanup¶
- π― Better DX - impossible to forget configuration
- β‘ Performance - library loads only when needed
- π§ Less maintenance - fewer front matter fields
- π Cleaner content - standard markdown syntax
Migration Steps¶
Step 1: Update Theme¶
Ensure you're using zer0-mistakes v0.5.0+:
Step 2: Test Your Diagrams¶
-
Start local Jekyll server:
-
Visit pages with Mermaid diagrams
- Check browser console for "Mermaid diagrams detected" message
- Verify all diagrams render correctly
Step 3: Remove Front Matter Flags (Optional)¶
Search for files with mermaid: true:
Remove the flag from each file:
Step 4: Update Documentation¶
Update any internal documentation that mentions the old approach:
- Remove references to
mermaid: truerequirement - Update examples to show auto-detection
- Add notes about performance benefits
Technical Details¶
How Auto-Detection Works¶
- Content Scanning: Theme scans page content for ```mermaid blocks
- Dynamic Loading: Mermaid.js loads from CDN only when needed
- Automatic Rendering: Diagrams render with optimized theme settings
- Performance: Zero impact on pages without diagrams
Detection Methods¶
The theme detects Mermaid content through:
- ``mermaid code blocks in markdown
-
HTML elements
-mermaid: true` front matter (backwards compatibility)
Performance Impact¶
Before:
- Mermaid.js loaded site-wide if any post had mermaid: true
- ~200KB library loaded on every page
After: - Mermaid.js loads only on pages with diagrams - Zero impact on pages without diagrams - Improved site performance
Troubleshooting¶
Diagrams Not Rendering?¶
- Check theme version: Ensure zer0-mistakes v0.5.0+
- Browser console: Look for "Mermaid diagrams detected" message
- Syntax validation: Test at mermaid.live
- Network tab: Verify Mermaid.js loads from CDN
Common Issues¶
Issue: Old posts with mermaid: true don't work
- Solution: Update theme to v0.5.0+
- Solution: Check browser console for errors
Issue: New posts without mermaid: true don't work
- Solution: Ensure theme is updated
- Solution: Check for syntax errors in diagrams
Issue: Performance seems slower - Solution: This shouldn't happen - auto-detection is faster - Solution: Check for multiple Mermaid.js loads in network tab
Rollback Plan¶
If you need to rollback to manual configuration:
- Revert theme: Use zer0-mistakes v0.4.0
- Add flags: Add
mermaid: trueto all posts with diagrams - Test: Verify diagrams render correctly
Benefits Summary¶
Developer Experience¶
- β Zero configuration required
- β Impossible to forget setup
- β Standard markdown syntax
- β Better error messages
Performance¶
- β On-demand loading only
- β Faster page loads
- β Reduced bandwidth usage
- β Better caching
Maintenance¶
- β Fewer front matter fields
- β Cleaner content files
- β Less configuration drift
- β Easier onboarding
Support¶
If you encounter issues during migration:
- Check documentation: Mermaid Guide
- Test syntax: Mermaid Live Editor
- Browser console: Look for error messages
- Theme version: Ensure v0.5.0+ is installed
Next Steps¶
- Update theme to zer0-mistakes v0.5.0+
- Test diagrams on local development server
- Remove flags from front matter (optional)
- Update documentation to reflect new approach
- Enjoy the improved developer experience!
This migration guide is part of the zer0-mistakes theme v0.5.0 release. For more information, visit the theme documentation.