/** * Convert Research Blog Post from Markdown to HTML * * Converts the research announcement blog post content from markdown to HTML * using the markdown.util.js utility. */ const { getCollection, connect, close } = require('../src/utils/db.util'); const { markdownToHtml } = require('../src/utils/markdown.util'); const SLUG = 'tractatus-research-working-paper-v01'; async function convertBlogPost() { try { console.log('šŸ”„ Converting research blog post to HTML...\n'); await connect(); const collection = await getCollection('blog_posts'); // Find the blog post const post = await collection.findOne({ slug: SLUG }); if (!post) { console.error('āŒ Blog post not found:', SLUG); console.log(' Run: node scripts/seed-research-announcement-blog.js'); return; } console.log('šŸ“ Found blog post:', post.title); console.log(' Current content type:', post.content.startsWith('<') ? 'HTML' : 'Markdown'); // Convert content to HTML const htmlContent = markdownToHtml(post.content); // Update the blog post await collection.updateOne( { slug: SLUG }, { $set: { content: htmlContent } } ); console.log('\nāœ… Blog post converted successfully'); console.log(' Slug:', SLUG); console.log(' HTML length:', htmlContent.length, 'characters'); console.log(''); console.log('šŸ“ Preview at: http://localhost:9000/blog-post.html?slug=' + SLUG); } catch (error) { console.error('āŒ Error converting blog post:', error); throw error; } finally { await close(); } } // Run if called directly if (require.main === module) { convertBlogPost() .then(() => { console.log('\n✨ Conversion complete'); process.exit(0); }) .catch(error => { console.error('\nšŸ’„ Conversion failed:', error); process.exit(1); }); } module.exports = { convertBlogPost };