Action
Create month log
Creates the current month with week numbers in the style of a Bullet Journal layout. Made with ChatGPT.
Steps
-
script
// See online documentation for examples // https://docs.getdrafts.com/docs/actions/scripting // Get the current date and month let today = new Date(); let year = today.getFullYear(); let month = (today.getMonth() + 1).toString().padStart(2, '0'); // Add 1 to month since it's zero-based // Format the draft title as # YYYY-MM let draftTitle = `# ${year}-${month}`; // Initialize the content with the title let draftContent = draftTitle + "\n\n"; // Get the number of days in the current month let daysInMonth = new Date(year, today.getMonth() + 1, 0).getDate(); // Helper array for day names const dayNames = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; // Track the current week number, starting with the first Sunday let currentWeek = 0; // Build the content for each day for (let day = 1; day <= daysInMonth; day++) { let date = new Date(year, today.getMonth(), day); let dayOfWeek = date.getDay(); // Sunday = 0, Monday = 1, ..., Saturday = 6 // Calculate the week number, starting with the first Sunday let weekNumber = Math.floor((day + 6 - dayOfWeek) / 7) + 1; // If it's the first day of a new week (Sunday), add the spacer and week number if (dayOfWeek === 0 || currentWeek !== weekNumber) { currentWeek = weekNumber; draftContent += `---\nWeek ${currentWeek}\n\n`; } // Add the day entry with a blank line afterward draftContent += `${day}-${dayNames[dayOfWeek]}\n\n`; } // Create the new draft let newDraft = Draft.create(); newDraft.content = draftContent; newDraft.update(); console.log(`Draft titled "${draftTitle}" created successfully!`);
Options
-
After Success Default Notification Info Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.