SuperAPI AI Directory

xhs-cover

Frontend & websites

View repository

Updated 10-15 17:33

About this skill

Generate a Xiaohongshu-style cover image for the user.

Input

Content provided by the user: $ARGUMENTS

Parse the input:

  • Title copy (required): extract the core copy from the input, no more than 30 characters
  • Style (optional):--style 风格名, auto-select by default

Available styles

1. morandi

Gentle and premium, low saturation, suitable for knowledge sharing, methodology, lifestyle

背景: linear-gradient(155deg, #f0e6d8, #e8dcd0, #d6cfc8)
主色: #c45c4a(暖红)
副色: #5b5080(灰紫)
辅助: #4a7a6a(灰绿)
文字: #3d3328(深棕)
标签背景: rgba(255,255,255,0.55)

2. academic (Academic Blue)

Calm and professional, suitable for paper interpretation, research sharing, technical analysis

背景: linear-gradient(155deg, #e4eaf2, #d8e2ee, #cdd8e8)
主色: #2563eb(学术蓝)
副色: #7c3aed(紫)
辅助: #0891b2(青)
文字: #1e293b(深蓝灰)
标签背景: rgba(255,255,255,0.6)

3. dark (Dark Tech)

Hardcore tech feel, suitable for AI/programming/open-source projects, in-depth technical content

背景: linear-gradient(155deg, #1a1a2e, #16213e, #0f3460)
主色: #a78bfa(亮紫)
副色: #38bdf8(天蓝)
辅助: #34d399(绿)
文字: #f1f5f9(近白)
标签背景: rgba(255,255,255,0.08), border: rgba(255,255,255,0.2)

4. mint (Fresh Mint)

Fresh and natural, suitable for tool recommendations, productivity methods, study notes

背景: linear-gradient(155deg, #ecfdf5, #e0f7ed, #d1f0e4)
主色: #059669(翠绿)
副色: #7c3aed(紫)
辅助: #d97706(琥珀)
文字: #1a3a2a(深绿灰)
标签背景: rgba(255,255,255,0.6)

5. sunset (Warm Sunset Orange)

Warm and energetic, suitable for personal reflections, project launches, milestone sharing

背景: linear-gradient(155deg, #fef3e2, #fde8d0, #fcdcc4)
主色: #ea580c(橘红)
副色: #7c3aed(紫)
辅助: #0891b2(青)
文字: #431407(深棕)
标签背景: rgba(255,255,255,0.55)

6. bw (Minimalist Black and White)

Premium and restrained, suitable for opinion pieces, controversial topics, deep thinking

背景: linear-gradient(155deg, #f5f5f5, #ebebeb, #e0e0e0)
主色: #18181b(纯黑)
副色: #52525b(灰)
辅助: #a1a1aa(浅灰)
文字: #18181b(纯黑)
标签背景: rgba(255,255,255,0.7), border: #d4d4d8

Generation process

Step 1: Design the copy

Extract from user input:

  • Main title(largest text, 1 line, core concept/product name/keyword)
  • Subtitle(second-largest text, 1-2 lines, core insight or tagline)
  • Tags(3 feature/keyword tags, each 2-4 characters)
  • Corner label(small text in the top-left, identity label such as OPEN SOURCE / paper interpretation / tool recommendation)
  • Bottom(small text, 3 keywords separated by ·)

Step 2: Choose the style

  • If the user specified --style, use the corresponding style
  • Otherwise auto-select based on the content:
    • Paper/research → academic
    • AI/programming/open source → dark or morandi
    • Tools/productivity → mint
    • Personal reflections/launches → sunset
    • Opinions/thinking → bw

Step 3: Generate the HTML

Write to /tmp/xhs-cover.html, following the template structure below:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
  * { margin: 0; padding: 0; box-sizing: border-box; }
  body { width: 1080px; height: 1440px; overflow: hidden;
         font-family: -apple-system, "PingFang SC", "Helvetica Neue", sans-serif; }
  .canvas {
    width: 1080px; height: 1440px;
    background: {风格背景};
    display: flex; flex-direction: column; justify-content: center;
    padding: 60px 70px; gap: 36px; position: relative;
  }
  /* 角标 */
  .badge { display: inline-flex; align-items: center; gap: 10px;
           background: {主色 alpha 0.12}; border: 1.5px solid {主色 alpha 0.2};
           border-radius: 10px; padding: 12px 24px; font-size: 28px;
           font-weight: 700; color: {主色}; letter-spacing: 3px; width: fit-content; }
  /* 主标题行 */
  .title-row { display: flex; align-items: baseline; gap: 20px; white-space: nowrap; }
  .title-main { font-size: 120-130px; font-weight: 900; color: {主色}; letter-spacing: -2px; }
  .title-secondary { font-size: 110-120px; font-weight: 900; color: {副色}; }
  /* 分隔线 */
  .divider { width: 80px; height: 5px;
             background: linear-gradient(90deg, {主色}, {副色});
             border-radius: 3px; margin: 10px 0; }
  /* 副标题 */
  .tagline { font-size: 76-82px; font-weight: 800; color: {文字色};
             letter-spacing: 8px; line-height: 1.4; }
  .tagline .accent { color: {主色 或副色 淡化}; }
  /* 标签 */
  .chip { background: {标签背景}; border-radius: 14px; padding: 18px 32px;
          font-size: 34px; font-weight: 700; letter-spacing: 2px; }
  /* 底部 */
  .footer { font-size: 30px; color: {文字色 淡化}; font-weight: 600; letter-spacing: 2px; }
</style>
</head>
<body>
  <!-- 按上面的结构填充内容 -->
</body>
</html>

Key design constraints:

  • 3:4 ratio (1080×1440px)
  • Text occupies more than 70% of the canvas
  • Keep the main title on one line if possible (reduce font size or split lines if necessary)
  • 2-3 levels of text hierarchy: main title > subtitle > tags/bottom
  • Use font-weight: 700-900 for all Chinese text
  • Use at most 3 colors (primary + secondary + accent), not cluttered

Step 4: Screenshot

Take and save a screenshot with Playwright:

from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1080, "height": 1440})
    page.goto("file:///tmp/xhs-cover.html")
    page.wait_for_timeout(500)
    page.screenshot(path="<输出路径>", full_page=False)
    browser.close()

Saved to ~/Documents/Obsidian Vault/xhs/img/cover-{简短标识}.png。

by default

Use the Read tool to show the generated image to the user and ask whether adjustments are needed.