mcpField
A
astro-cta-injector

astro-cta-injector

github.com/nicepkg营销与增长28898 次安装40 周前更新
代码仓库

关于 astro-cta-injector

为 Astro 内容站点批量插入行动号召(CTA)的技能,面向管理博客内容的团队。它根据内容相关性评分并提供预览、备份和回滚,支持多种 CTA 类型与放置方式。

主要功能

  1. 01按关键词和主题评估内容相关性
  2. 02支持 newsletter、产品和自定义 CTA
  3. 03按段落、标题等策略放置
  4. 04批量预览并显示差异
  5. 05默认试运行并支持备份和回滚

适用场景

  1. 01为相关博客文章添加 newsletter 注册区块
  2. 02向产品相关内容批量插入推广链接
  3. 03预览并确认多个 Astro 文件的修改

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/nicepkg/ai-workflow --skill astro-cta-injector

安装后在 Claude Code 中输入/astro-cta-injector确认已加载。

包含的文件

除 SKILL.md 外,安装时一起下载的参考资料和脚本。

config.example.json
reference.md
scripts/
inject_ctas.py
preview_injection.py
score_posts.py
templates/
newsletter.html
product.html

详细介绍

Astro CTA 注入技能

用途

此技能可将行动号召(CTA)区块注入 Astro 网站内容。它支持:

  • 多种 CTA 类型(newsletter、产品、自定义)
  • 智能放置策略
  • 基于内容的相关性评分
  • 带预览的批量处理

何时使用此技能

  • 用户要求“为博客文章添加 CTA”
  • 用户希望在内容中“注入 newsletter 注册表单”
  • 用户提到要在文章中“添加产品推广”
  • 用户需要批量向文章添加任意类型的内容区块
  • 用户希望“向 Astro 网站添加行动号召”

前提条件

  • Astro 网站,内容位于 .astro 或 .md 文件中
  • Python 3.10+
  • 用于 HTML 解析的 BeautifulSoup4

配置

在技能目录中创建一个 config.json:

{
  "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
}

放置策略

策略说明最适合
end所有内容之后不打扰读者的 CTA
after-paragraph-50%在 50% 的段落之后在内容中段吸引互动
after-paragraph-60%在 60% 的段落之后在内容后段吸引互动
after-heading第一个 H2 之后尽早吸引互动
before-conclusion最后一段之前强有力的收尾

CTA 模板

模板是 templates/ 目录中的 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>

变量:

  • {{title}} - CTA 标题
  • {{description}} - CTA 正文
  • {{form_url}} - 表单提交 URL
  • {{product_url}} - 产品链接
  • {{image_url}} - 图片来源

工作流

步骤 1:评估文章的相关性
python scripts/score_posts.py --content-path ./src/content/blog --cta-type newsletter
步骤 2:预览注入效果
python scripts/preview_injection.py --input scored_posts.json --cta-type newsletter
步骤 3:应用注入
python scripts/inject_ctas.py --input scored_posts.json --cta-type newsletter

输入格式

已评分文章的 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"
      }
    }
  ]
}

评分算法

根据 CTA 相关性对文章评分,依据如下:

  1. 关键词密度 - 出现了多少个相关关键词
  2. 内容长度 - 文章越长,越适合作为候选
  3. 主题匹配度 - 标题与内容的主题一致性
  4. 现有 CTA - 跳过已有 CTA 的文章

评分范围为 0-10。默认阈值:5.0

安全功能

  • 默认启用试运行模式
  • 修改前创建备份
  • 重复项检测 - 如果 CTA 已存在,则不会注入
  • 回滚功能 - 从备份中恢复
  • 差异预览 - 精确查看将要发生的更改

使用示例

用户:“为我所有与效率相关的博客文章添加 newsletter 注册 CTA”

Claude 将会:

  1. 扫描内容目录中的文章
  2. 使用效率关键词为文章评估“newsletter”相关性
  3. 根据模板生成 CTA HTML
  4. 显示更改预览
  5. 请求确认
  6. 向匹配的文章注入 CTA
  7. 报告结果

评论

支持 Markdown