← 返回
未分类 Key 中文

Sanity Cms

Publish content to any Sanity CMS instance. Use when asked to create a Sanity draft, push a document to Sanity, upload an image asset to Sanity, or convert c...
将内容发布到任意 Sanity CMS 实例。适用于创建 Sanity 草稿、向Sanity 推送文档、上传图片资源到 Sanity,或进行内容转换等需求。
squidpunch squidpunch 来源
未分类 clawhub v1.0.2 1 版本 100000 Key: 需要
★ 0
Stars
📥 382
下载
💾 0
安装
1
版本
#latest

概述

Sanity CMS Skill

Publishes documents to Sanity CMS via the Content API. Works with any schema.

References

  • API patterns (upload, mutate, query): references/api.md
  • Portable Text body format: references/portable-text.md

Workflow

1. Understand the target schema

Four ways to get schema info — try in this order:

A — File in workspace: User drops schema at a known path (e.g. sanity-schemas/blogPost.ts). Read it directly.

B — Pasted in chat: User pastes the schema TypeScript/JS. Read it from the conversation.

C — Remote URL: User shares a GitHub raw URL or similar. Fetch with web_fetch.

D — API introspection (no file needed): Query the dataset directly — see references/api.md (Schema Introspection section). Use array::unique(*[]._type) to discover document types, then fetch one sample document to infer field names and shapes. Works without any schema file at all.

Once you have the schema (by any method):

  • For array fields with type: 'block', use Portable Text format — see references/portable-text.md
  • For reference fields (categories, authors, tags), query existing documents via GROQ — see references/api.md

2. Format the document JSON

Build a JSON object matching the schema:

  • Omit _id — the script generates a drafts. prefixed UUID automatically
  • Omit the cover image field — the script injects it after uploading
  • All required fields must be present and within any validation constraints
  • Save to a logical path (e.g. brain/projects/-sanity.json or similar)

3. Run the publish script

The script is at scripts/publish_draft.sh within this skill directory. Resolve the path relative to where the skill is installed (e.g. ~/.openclaw/skills/sanity-cms/scripts/publish_draft.sh or /skills/sanity-cms/scripts/publish_draft.sh).

bash <skill-dir>/scripts/publish_draft.sh \
  path/to/document.json \
  path/to/cover-image.png   # optional

Optional env overrides:

VarDefaultPurpose
-----------------------
SANITY_DATASETproductionTarget dataset
COVER_IMAGE_FIELDcoverImageField name for cover image
DRAFT_PREFIXtrueSet to false to publish immediately

Example with overrides:

SANITY_DATASET=staging COVER_IMAGE_FIELD=mainImage \
  bash <skill-dir>/scripts/publish_draft.sh doc.json cover.jpg

4. Confirm and report

After the script prints a draft ID, report to the user:

  • The draft document ID
  • A link to Sanity Studio (ask if unsure of the Studio URL)
  • Which fields, if any, still need manual attention in Studio (e.g. unpopulated references)

Env Vars

VarDescription
------------------
SANITY_PROJECT_IDSanity project ID
SANITY_API_TOKENWrite-enabled token (Editor or higher)
SANITY_DATASETDataset (optional, default: production)

Tips

  • Always create drafts first (DRAFT_PREFIX=true) unless the user explicitly wants to publish live
  • If a schema has reference fields, query for the referenced document IDs via GROQ before building the JSON — see references/api.md
  • The script works with any document type: blog posts, pages, products, authors, etc.
  • Cover image upload is optional — omit the second argument if the schema has no image field

版本历史

共 1 个版本

  • v1.0.2 当前
    2026-05-07 08:50 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

dev-programming

Github

steipete
使用 `gh` CLI 与 GitHub 交互,通过 `gh issue`、`gh pr`、`gh run` 和 `gh api` 管理议题、PR、CI 运行及高级查询。
★ 679 📥 327,976
dev-programming

CodeConductor.ai

larsonreever
AI驱动平台,提供快速全栈开发、智能体、工作流自动化及低代码AI集成的可扩展产品创建。
★ 72 📥 182,026
dev-programming

Mcporter

steipete
使用 mcporter CLI 直接列出、配置、认证及调用 MCP 服务器/工具(支持 HTTP 或 stdio),涵盖临时服务器、配置编辑及 CLI/类型生成功能。
★ 195 📥 67,731