diff --git a/.cursor/rules/newsletter_processor.mdc b/.cursor/rules/newsletter_processor.mdc index 797fa54..0f18227 100644 --- a/.cursor/rules/newsletter_processor.mdc +++ b/.cursor/rules/newsletter_processor.mdc @@ -6,69 +6,121 @@ alwaysApply: false # Newsletter URL Processor ## Description -This rule processes URLs to create or update newsletter posts. When a single URL is provided, it will either create a new newsletter post or append to an existing one. +This rule processes URLs to create or update newsletter posts. When a single URL is provided, it will either create a new newsletter post or append to an existing one. The rule ensures consistent formatting and high-quality content in Vietnamese. ## Trigger - When a single URL is provided in the message +- When multiple URLs are provided in sequence ## Actions 1. URL Processing: - Remove tracking parameters (utm_source, ref, etc.) - Clean and preserve base URL - Extract original article title + - Verify URL accessibility + - Check for duplicate articles in existing newsletters 2. Newsletter Creation/Update: - - Check for existing newsletter file for current date + - Check for existing newsletter file for current date using one of these methods: + ```powershell + # Method 1: Using Get-Date with explicit format + Get-Date -Format "yyyy-MM-dd" + + # Method 2: Using .NET DateTime directly + [DateTime]::Now.ToString("yyyy-MM-dd") + + # Method 3: Using date command (if PowerShell fails) + date +%Y-%m-%d + ``` - If exists: append new content - If not: create new file with proper structure + - Auto-increment newsletter number based on latest existing newsletter 3. Content Structure: ```markdown --- title: "Newsletter #[number]" - date: [current date] + date: [current date using one of the above methods] tags: [ "AI-Assisted", [additional relevant tags] ] categories: [ "Newsletter" ] --- *Mời bạn thưởng thức Newsletter #[number].* - ## Main Content - [New content URLs and summaries should be added here, before any bonus sections] - ## [Original Article Title](mdc:clean_url) - [Vietnamese summary] + [Vietnamese summary in professional tone] [Optional bullet points for key takeaways] - ## Bonus Content - [Any additional bonus content should be placed after the main content] + [New content URLs and summaries should be added before any bonus sections] ``` 4. File Location: - Store in: content/post/YYYY/MM/DD/index.md + - Use one of the date methods above for date formatting + - Create directory structure if not exists -## Requirements -- Summaries must be in Vietnamese -- Maintain professional tone -- Include key points in bullet format when appropriate -- Keep summaries concise but informative -- Add relevant tags based on article content -- Always include "AI-Assisted" tag +## Content Guidelines +1. Vietnamese Summaries: + - Write in professional, clear Vietnamese + - Keep technical terms in English when appropriate + - Maintain consistent tone throughout + - Length: 2-4 paragraphs for main content + - Include key takeaways in bullet points when relevant + +2. Tagging: + - Always include "AI-Assisted" tag + - Add relevant technical tags (e.g., "Development", "Architecture", "Java") + - Use consistent tag naming across newsletters + - Maximum 5 tags per newsletter + +3. Formatting: + - Use proper markdown syntax + - Maintain consistent heading levels + - Include proper spacing between sections + - Use bullet points for lists + - Keep URLs clean and readable ## Quality Checks -- Verify URL accessibility -- Check for duplicate articles -- Ensure proper date formatting -- Validate markdown syntax -- Maintain consistent formatting -- Check Vietnamese language quality -- Verify all links are working +1. Content: + - Verify URL accessibility + - Check for duplicate articles + - Ensure proper date formatting + - Validate markdown syntax + - Maintain consistent formatting + - Check Vietnamese language quality + - Verify all links are working + +2. Technical: + - Validate front matter format + - Check directory structure + - Verify newsletter number sequence + - Ensure proper file naming + - Validate date format consistency ## Example Input: https://example.com/article?utm_source=twitter -Output: Creates or updates newsletter post with cleaned URL and Vietnamese summary +Output: Creates or updates newsletter post with: +- Clean URL: https://example.com/article +- Vietnamese summary +- Proper front matter +- Correct file location +- Appropriate tags +## Error Handling +- If URL is inaccessible: Skip and notify +- If duplicate found: Skip and notify +- If date format invalid: Use current date +- If directory creation fails: Notify and abort +- If markdown validation fails: Fix and retry + +## Date Handling Troubleshooting +If the primary date method fails, try these alternatives in order: +1. Use .NET DateTime directly: `[DateTime]::Now.ToString("yyyy-MM-dd")` +2. Use date command: `date +%Y-%m-%d` +3. Use JavaScript Date object: `new Date().toISOString().split('T')[0]` +4. Use Python datetime: `python -c "from datetime import datetime; print(datetime.now().strftime('%Y-%m-%d'))"` +Note: Always verify the date format matches the required "yyyy-MM-dd" pattern before using it in the newsletter. \ No newline at end of file