tractatus/scripts/move-guides-to-resources.js
TheFlow ce5dfdf7ad fix(docs): card overflow, sequencing, colour legend, and category fixes
Fixed multiple issues with the docs page card-based document view:

**Card Overflow Fixed:**
- Added overflow-x-hidden to #document-content container
- Added w-full max-w-full to card-grid-container
- Added w-full to grid itself
- Added max-w-full overflow-hidden to individual cards
- Cards now stay within container boundaries at all viewport sizes

**Long Title Wrapping:**
- Added insertSoftHyphens() method to break CamelCase words
- Inserts soft hyphens (­) before capitals in compound words
- Examples: "InstructionPersistenceClassifier" → "Instruction­Persistence­Classifier"
- Titles now wrap intelligently without being cut off

**Colour Legend (Option C):**
- Added toggle button (ℹ️) next to ToC and PDF buttons
- Popup shows all 5 colour codes with descriptions
- Translated to EN ("Colour Guide"), DE ("Farbcode"), FR ("Guide des couleurs")
- Fixed colour square visibility (bg-500 with borders instead of bg-400)
- Click outside to close functionality

**Card Sequencing:**
- Cards now display in original markdown document order
- Removed groupByCategory() grouping logic
- Removed category header sections
- Color coding preserved based on section category

**Category Fallback Bug:**
- Fixed invalid fallback category 'downloads-resources' → 'resources'
- Ensures uncategorized documents go to valid category

**Database Migration:**
- Added scripts/move-guides-to-resources.js
- Moved 3 implementation guides from getting-started to resources
- Getting Started now contains only: Introduction, Core Concepts
- Resources now contains: Implementation guides

**Result:**
 Cards respect container width (no overflow)
 Long titles wrap with hyphens (no cutoff)
 Colour legend accessible and translated
 Cards in logical reading order from markdown
 Implementation guides in correct category

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 11:03:23 +13:00

75 lines
2.1 KiB
JavaScript

const { MongoClient } = require('mongodb');
const MONGO_URI = 'mongodb://localhost:27017';
const DB_NAME = 'tractatus_dev';
async function moveGuidesToResources() {
const client = new MongoClient(MONGO_URI);
try {
await client.connect();
console.log('✓ Connected to MongoDB');
const db = client.db(DB_NAME);
const collection = db.collection('documents');
// Find implementation guides currently in getting-started
const guides = await collection.find({
category: 'getting-started',
$or: [
{ slug: { $regex: /implementation-guide/ } },
{ title: { $regex: /Implementation Guide/i } }
]
}).toArray();
console.log(`\nFound ${guides.length} implementation guide(s):`);
guides.forEach(doc => {
console.log(` - ${doc.title} (${doc.slug})`);
});
if (guides.length === 0) {
console.log('\n⚠ No guides to move (already in resources?)');
return;
}
// Update all implementation guides to resources category
const result = await collection.updateMany(
{
category: 'getting-started',
$or: [
{ slug: { $regex: /implementation-guide/ } },
{ title: { $regex: /Implementation Guide/i } }
]
},
{
$set: { category: 'resources' }
}
);
console.log(`\n✅ Updated ${result.modifiedCount} document(s)`);
console.log(' Category changed: getting-started → resources');
// Verify the change
const verifyGuides = await collection.find({
category: 'resources',
$or: [
{ slug: { $regex: /implementation-guide/ } },
{ title: { $regex: /Implementation Guide/i } }
]
}).toArray();
console.log(`\n✓ Verification: ${verifyGuides.length} guide(s) now in Resources:`);
verifyGuides.forEach(doc => {
console.log(` - ${doc.title}`);
});
} catch (error) {
console.error('❌ Error:', error.message);
process.exit(1);
} finally {
await client.close();
console.log('\n✓ Database connection closed');
}
}
moveGuidesToResources();