Migration Guide: Markdown to MDC
Step-by-step guide for migrating from traditional Markdown files to MDC (Markdown Components) format
🔄 Migration Guide: Markdown to MDC
This guide provides a comprehensive approach to migrating from traditional Markdown files to MDC (Markdown Components) format, enabling interactive documentation with enhanced features.
🎯 Migration Overview
What is MDC?
MDC (Markdown Components) extends traditional Markdown with:
- Interactive Components: Live Angular components and widgets
- AI Integration: AI-generated content and metadata
- Enhanced Frontmatter: Rich metadata and configuration
- Dynamic Content: Real-time data and conditional rendering
Migration Benefits
- Enhanced Interactivity: Live demos and interactive examples
- Better User Experience: Engaging, hands-on documentation
- AI-Powered Features: Intelligent content generation and suggestions
- Future-Proof: Ready for advanced documentation features
- Backward Compatibility: Existing
.mdfiles continue to work
📋 Pre-Migration Checklist
1. Assess Current Documentation
- Inventory all existing
.mdfiles - Identify high-value content for migration
- Review content that would benefit from interactivity
- Check for complex code examples that could be interactive
2. Plan Migration Strategy
- Choose migration approach (gradual vs. complete)
- Prioritize content by importance and complexity
- Set up testing environment
- Train team on MDC syntax and features
3. Prepare Infrastructure
- Ensure MDC support is enabled in docs-angular
- Set up component library access
- Configure AI integration if needed
- Test migration tools and processes
🚀 Migration Approaches
Approach 1: Gradual Migration (Recommended)
Migrate content incrementally, starting with high-value pages.
Phase 1: High-Impact Pages
- Getting Started guides
- API documentation with examples
- Tutorial content
- Component showcases
Phase 2: Standard Content
- Reference documentation
- Configuration guides
- Troubleshooting content
Phase 3: Legacy Content
- Archived documentation
- Historical content
- Low-traffic pages
Approach 2: Complete Migration
Migrate all content at once (suitable for smaller documentation sets).
📝 Step-by-Step Migration Process
Step 1: File Preparation
1.1 Rename File
# Rename .md to .mdc
mv getting-started.md getting-started.mdc
1.2 Update Frontmatter
Convert basic frontmatter to MDC format:
Before (.md):
---
title: Getting Started
description: Learn how to get started with our platform
author: GoGrab Team
lastUpdated: 2025-01-25
---
After (.mdc):
---
title: Getting Started
description: Learn how to get started with our platform
author: GoGrab Team
lastUpdated: 2025-01-25
type: mdc
interactive: true
status: published
difficulty: beginner
estimatedReadTime: 10
toc: true
searchable: true
breadcrumbs: true
sidebar: true
# UI configuration
ui:
showMetadata: true
enableInteraction: true
compactMode: false
# Performance configuration
performance:
lazyLoad: true
preload: false
cacheStrategy: normal
---
Step 2: Content Enhancement
2.1 Add Interactive Components
Code Examples:
<!-- Before: Static code block -->
```typescript
export class ExampleComponent {
@Input() title = 'Hello World';
}
<mdc:code-block language="typescript" interactive="true" theme="vs-dark"> export class ExampleComponent { @Input() title = 'Hello World'; }
**Live Demos:**
```markdown
<!-- Add interactive demos -->
<mdc:interactive-demo
component="ButtonComponent"
:props='{"variant": "primary", "size": "large"}'>
Try clicking this interactive button!
</mdc:interactive-demo>
Diagrams:
<!-- Add visual diagrams -->
<mdc:diagram
type="flowchart"
ai-prompt="Create a flowchart showing the setup process"
theme="modern">
</mdc:diagram>
2.2 Enhance with AI Features
<!-- Add AI-generated content sections -->
<mdc:ai-content
prompt="Explain the benefits of this approach"
confidence="0.95"
review-status="approved">
AI-generated insights and explanations.
</mdc:ai-content>
Step 3: Testing and Validation
3.1 Component Testing
- Verify all components render correctly
- Test interactive features
- Check responsive design
- Validate accessibility
3.2 Content Validation
- Review content accuracy
- Check for broken links
- Validate frontmatter syntax
- Test search functionality
3.3 Performance Testing
- Measure page load times
- Test with slow connections
- Verify lazy loading works
- Check memory usage
Step 4: Deployment and Monitoring
4.1 Deploy Changes
- Deploy to staging environment
- Test with real users
- Monitor for errors
- Collect feedback
4.2 Monitor Performance
- Track page load times
- Monitor component errors
- Check user engagement
- Analyze usage patterns
🛠️ Migration Tools and Automation
Automated Migration Script
Create a script to automate basic migration tasks:
// migrate-to-mdc.js
const fs = require('fs');
const path = require('path');
function migrateMarkdownToMDC(filePath) {
const content = fs.readFileSync(filePath, 'utf8');
// Add MDC frontmatter
const mdcContent = addMDCFrontmatter(content);
// Convert code blocks to interactive components
const enhancedContent = convertCodeBlocks(mdcContent);
// Save as .mdc file
const newPath = filePath.replace('.md', '.mdc');
fs.writeFileSync(newPath, enhancedContent);
console.log(`Migrated: ${filePath} -> ${newPath}`);
}
function addMDCFrontmatter(content) {
const frontmatterMatch = content.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
if (frontmatterMatch) {
const existingFrontmatter = frontmatterMatch[1];
const body = frontmatterMatch[2];
// Add MDC-specific fields
const mdcFrontmatter = addMDCFields(existingFrontmatter);
return `---\n${mdcFrontmatter}\n---\n${body}`;
} else {
// Add basic MDC frontmatter
const basicFrontmatter = `title: "Document Title"
type: mdc
interactive: true
status: published
toc: true
searchable: true`;
return `---\n${basicFrontmatter}\n---\n\n${content}`;
}
}
function convertCodeBlocks(content) {
// Convert ```language blocks to mdc:code-block components
return content.replace(/```(\w+)\n([\s\S]*?)```/g,
'<mdc:code-block language="$1" interactive="true">\n$2\n</mdc:code-block>');
}
Manual Migration Checklist
For each file, verify:
- Frontmatter: All required MDC fields present
- Components: Interactive components work correctly
- Links: All internal and external links functional
- Images: Images display correctly
- Code: Code blocks are properly formatted
- Navigation: File appears in navigation
- Search: Content is searchable
- Mobile: Responsive design works on mobile
🎨 Content Enhancement Strategies
1. Interactive Code Examples
Before:
Here's how to create a component:
```typescript
@Component({
selector: 'app-example',
template: '<h1>{{ title }}</h1>'
})
export class ExampleComponent {
title = 'Hello World';
}
**After:**
```markdown
Here's how to create a component:
<mdc:code-block
language="typescript"
interactive="true"
theme="vs-dark">
@Component({
selector: 'app-example',
template: '<h1>{{ title }}</h1>'
})
export class ExampleComponent {
title = 'Hello World';
}
</mdc:code-block>
Try editing the code above to see live changes!
2. Live Component Demos
Before:
Our button component supports different variants:
- Primary button
- Secondary button
- Danger button
After:
Our button component supports different variants:
<mdc:interactive-demo
component="ButtonShowcase"
:props='{"showVariants": true}'>
Try different button variants and see them in action!
</mdc:interactive-demo>
3. Visual Diagrams
Before:
The system architecture follows this flow:
1. User makes request
2. API processes request
3. Database stores data
4. Response sent to user
After:
The system architecture follows this flow:
<mdc:diagram
type="flowchart"
ai-prompt="Create a flowchart showing the system architecture flow"
theme="modern"
interactive="true">
</mdc:diagram>
4. AI-Enhanced Content
Before:
This approach provides several benefits:
- Better performance
- Improved maintainability
- Enhanced user experience
After:
<mdc:ai-content
prompt="Explain the benefits of this architectural approach"
confidence="0.92"
review-status="approved">
This approach provides several key benefits that make it ideal for modern applications.
</mdc:ai-content>
🚨 Common Migration Issues
Issue 1: Frontmatter Parsing Errors
Problem: YAML frontmatter syntax errors Solution: Validate YAML syntax and ensure proper indentation
# Correct
ui:
showMetadata: true
enableInteraction: true
# Incorrect
ui:
showMetadata: true
enableInteraction: true
Issue 2: Component Not Rendering
Problem: Components don't appear in rendered output Solution: Check component syntax and ensure components are registered
<!-- Correct -->
<mdc:code-block language="typescript">
// Code here
</mdc:code-block>
<!-- Incorrect -->
<mdc:code-block language="typescript"
// Code here
</mdc:code-block>
Issue 3: Performance Issues
Problem: Slow page loading with many components Solution: Enable lazy loading and optimize component usage
# In frontmatter
performance:
lazyLoad: true
preload: false
cacheStrategy: normal
Issue 4: Mobile Responsiveness
Problem: Components don't work well on mobile Solution: Test responsive design and adjust component properties
<mdc:interactive-demo
component="ResponsiveComponent"
:props='{"mobileOptimized": true}'>
</mdc:interactive-demo>
📊 Migration Metrics
Track These Metrics
- Migration Progress: Percentage of files migrated
- Component Usage: Most used component types
- Performance Impact: Page load time changes
- User Engagement: Time spent on pages
- Error Rates: Component rendering errors
Success Criteria
- All high-priority content migrated
- No increase in page load times > 20%
- User engagement increased by > 30%
- Error rate < 1%
- Mobile experience maintained
🔄 Rollback Plan
If Migration Fails
Immediate Rollback
- Revert to previous version
- Restore original
.mdfiles - Disable MDC features
Investigation
- Identify root cause
- Fix issues
- Test thoroughly
Re-attempt Migration
- Apply fixes
- Test in staging
- Deploy gradually
🎯 Post-Migration Optimization
1. Performance Tuning
- Monitor component performance
- Optimize heavy components
- Implement caching strategies
2. Content Updates
- Add more interactive examples
- Enhance with AI features
- Regular content reviews
3. User Training
- Train content authors on MDC
- Create style guides
- Provide templates
🔗 Resources and Support
Documentation
Tools
- Migration scripts and utilities
- Component testing tools
- Performance monitoring
Support
- Development team support
- Community forums
- Issue tracking system
This migration guide is maintained by the GoGrab Development Team and is updated regularly based on user feedback and new features.