Files
blog/.github/instructions/newsletter_processor.instructions.md
T
2025-05-10 22:59:47 +07:00

4.0 KiB

applyTo
applyTo
*.md

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. 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 using one of these methods:
      # 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:

    ---
    title: "Newsletter #[number]"
    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].*
    
    ## [Original Article Title](mdc:clean_url)
    
    [Vietnamese summary in professional tone]
    
    [Optional bullet points for key takeaways]
    
    [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

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

  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:

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.