#!/usr/bin/env node import fs from 'node:fs' import path from 'node:path' const args = process.argv.slice(2) const topic = args[0] || '' // Get current date const date = new Date() const dateStr = date.toISOString().split('T')[0] // YYYY-MM-DD const dayName = date.toLocaleDateString('zh-CN', { weekday: 'long' }) // File name const filename = topic ? `${dateStr} - ${topic}.md` : `${dateStr}.md` // Check if file exists if (fs.existsSync(filename)) { console.log(`❌ File already exists: ${filename}`) console.log('Opening existing file...') process.exit(1) } // Template path const templatePath = path.join( '06_Metadata', 'Templates', 'Daily Note Template.md', ) if (!fs.existsSync(templatePath)) { console.log(`❌ Template not found: ${templatePath}`) process.exit(1) } // Read template const template = fs.readFileSync(templatePath, 'utf-8') // Replace template variables let content = template .replace(/\{\{date:YYYY-MM-DD\}\}/g, dateStr) .replace(//g, '') // Write to file fs.writeFileSync(filename, content, 'utf-8') console.log(`✅ Created daily note: ${filename}`) console.log(`📝 Location: ${path.join(process.cwd(), filename)}`)