Get the FREE Ultimate OpenClaw Setup Guide →

astro-cta-injector

Scanned
npx machina-cli add skill nicepkg/ai-workflow/astro-cta-injector --openclaw
Files (1)
SKILL.md
4.4 KB

Astro CTA Injector Skill

Purpose

This skill injects Call-to-Action (CTA) blocks into Astro site content. It supports:

  • Multiple CTA types (newsletter, product, custom)
  • Intelligent placement strategies
  • Content-based relevance scoring
  • Batch processing with preview

When to Use This Skill

  • User asks to "add CTAs to blog posts"
  • User wants to "inject newsletter signup" into content
  • User mentions "add product promotion" to posts
  • User needs to batch-add any type of content block to posts
  • User wants to "add calls to action" to their Astro site

Prerequisites

  • Astro site with content in .astro or .md files
  • Python 3.10+
  • BeautifulSoup4 for HTML parsing

Configuration

Create a config.json in the skill directory:

{
  "content_path": "./src/content/blog",
  "file_patterns": ["*.astro", "*.md"],
  "cta_types": {
    "newsletter": {
      "template": "newsletter.html",
      "default_placement": "after-paragraph-50%",
      "keywords": ["tip", "guide", "learn", "strategy"]
    },
    "product": {
      "template": "product.html",
      "default_placement": "end",
      "keywords": ["productivity", "task", "habit", "goal"]
    }
  },
  "output": {
    "state_file": "./state/cta_injection_progress.json",
    "backup_dir": "./backups",
    "report_file": "./reports/cta_injection_report.md"
  },
  "dry_run": true
}

Placement Strategies

StrategyDescriptionBest For
endAfter all contentNon-intrusive CTAs
after-paragraph-50%After 50% of paragraphsMid-content engagement
after-paragraph-60%After 60% of paragraphsLater engagement
after-headingAfter first H2Early engagement
before-conclusionBefore last paragraphStrong finish

CTA Templates

Templates are HTML files in the templates/ directory:

<!-- templates/newsletter.html -->
<aside class="cta-newsletter" data-cta-type="newsletter">
  <h3>{{title}}</h3>
  <p>{{description}}</p>
  <form action="{{form_url}}" method="post">
    <input type="email" placeholder="Your email" required />
    <button type="submit">Subscribe</button>
  </form>
</aside>

Variables:

  • {{title}} - CTA headline
  • {{description}} - CTA body text
  • {{form_url}} - Form submission URL
  • {{product_url}} - Product link
  • {{image_url}} - Image source

Workflow

Step 1: Score Posts for Relevance

python scripts/score_posts.py --content-path ./src/content/blog --cta-type newsletter

Step 2: Preview Injections

python scripts/preview_injection.py --input scored_posts.json --cta-type newsletter

Step 3: Apply Injections

python scripts/inject_ctas.py --input scored_posts.json --cta-type newsletter

Input Format

Scored posts JSON:

{
  "posts": [
    {
      "file_path": "./src/content/blog/my-post.astro",
      "title": "My Blog Post",
      "relevance_score": 8.5,
      "cta_type": "newsletter",
      "placement": "after-paragraph-50%",
      "cta_data": {
        "title": "Get More Tips Like This",
        "description": "Subscribe to my weekly newsletter"
      }
    }
  ]
}

Scoring Algorithm

Posts are scored for CTA relevance based on:

  1. Keyword density - How many relevant keywords appear
  2. Content length - Longer posts = better candidates
  3. Topic match - Title and content topic alignment
  4. Existing CTAs - Skip posts that already have CTAs

Scores range from 0-10. Default threshold: 5.0

Safety Features

  • Dry-run mode by default
  • Backup creation before any modifications
  • Duplicate detection - Won't inject if CTA already exists
  • Rollback capability - Restore from backups
  • Preview diffs - See exactly what will change

Example Usage

User: "Add a newsletter signup CTA to all my productivity-related blog posts"

Claude will:

  1. Scan content directory for posts
  2. Score posts for "newsletter" relevance using productivity keywords
  3. Generate CTA HTML from template
  4. Show preview of changes
  5. Ask for confirmation
  6. Inject CTAs into matching posts
  7. Report results

Source

git clone https://github.com/nicepkg/ai-workflow/blob/main/workflows/content-creator-workflow/.claude/skills/astro-cta-injector/SKILL.mdView on GitHub

Overview

This skill injects CTA blocks into Astro site content, supporting newsletter, product, and custom CTAs with intelligent placement. It uses content relevance scoring and multiple placement strategies to insert CTAs without disrupting reading flow, and includes batch processing with a dry-run preview.

How This Skill Works

It analyzes Astro (.astro) and Markdown (.md) content, scores posts for relevance based on keyword density, length, topic match, and existing CTAs, then selects a CTA type and placement using configured rules. CTAs are rendered from HTML templates in templates/ with variables like title, description, and form_url, and the workflow runs scoring, preview, and then applying injections, with dry-run enabled by default and automatic backups.

When to Use It

  • User asks to add CTAs to blog posts
  • User wants to inject newsletter signup into content
  • User mentions adding product promotions to posts
  • User needs to batch-add any type of content block to posts
  • User wants to add calls to action to their Astro site

Quick Start

  1. Step 1: Configure config.json with content_path, file_patterns, and CTA types
  2. Step 2: Run scoring: python scripts/score_posts.py --content-path ./src/content/blog --cta-type newsletter
  3. Step 3: Preview injections: python scripts/preview_injection.py --input scored_posts.json --cta-type newsletter

Best Practices

  • Configure content_path and file_patterns to match your site structure
  • Ensure CTA templates (newsletter.html, product.html) exist and align with your design
  • Always run in dry-run first and review the generated preview/report
  • Create backups before applying injections
  • Tune keywords and topic signals in cta_types to improve relevance scoring

Example Use Cases

  • Insert a newsletter CTA after 50% of paragraphs in a long post for mid-content engagement
  • Place a product promo CTA at the end of a tutorial or guide
  • Inject a custom CTA block after the first heading to boost early interaction
  • Batch-inject newsletters across a set of posts using the scoring results
  • Preview CTAs on a batch of posts before publishing product announcements

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers