返回顶部
s

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 content into a Sanity-formatted document. Works with any document type and schema — not limited to blog posts. Requires SANITY_PROJECT_ID and SANITY_API_TOKEN env vars.

作者: admin | 来源: ClawHub
源自
ClawHub
版本
V 1.0.2
安全检测
已通过
81
下载量
0
收藏
概述
安装方式
版本历史

sanity-cms

# 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/<slug>-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 `<workspace>/skills/sanity-cms/scripts/publish_draft.sh`). ```bash bash <skill-dir>/scripts/publish_draft.sh \ path/to/document.json \ path/to/cover-image.png # optional ``` **Optional env overrides:** | Var | Default | Purpose | |-----|---------|---------| | `SANITY_DATASET` | `production` | Target dataset | | `COVER_IMAGE_FIELD` | `coverImage` | Field name for cover image | | `DRAFT_PREFIX` | `true` | Set to `false` to publish immediately | Example with overrides: ```bash 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 | Var | Description | |-----|-------------| | `SANITY_PROJECT_ID` | Sanity project ID | | `SANITY_API_TOKEN` | Write-enabled token (Editor or higher) | | `SANITY_DATASET` | Dataset (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

标签

skill ai

通过对话安装

该技能支持在以下平台通过对话安装:

OpenClaw WorkBuddy QClaw Kimi Claude

方式一:安装 SkillHub 和技能

帮我安装 SkillHub 和 sanity-cms-1776116495 技能

方式二:设置 SkillHub 为优先技能安装源

设置 SkillHub 为我的优先技能安装源,然后帮我安装 sanity-cms-1776116495 技能

通过命令行安装

skillhub install sanity-cms-1776116495

下载 Zip 包

⬇ 下载 sanity-cms v1.0.2

文件大小: 6.36 KB | 发布时间: 2026-4-14 14:37

v1.0.2 最新 2026-4-14 14:37
- Expanded schema discovery options: now supports reading schemas from workspace files, chat pastes, remote URLs, or direct API introspection without a file.
- Added details for API-driven schema discovery (listing types and inferring fields from sample documents).
- Clarified instructions for handling missing schema files and using GROQ queries.
- Documentation in SKILL.md updated for improved usability and guidance.

Archiver·手机版·闲社网·闲社论坛·羊毛社区· 多链控股集团有限公司 · 苏ICP备2025199260号-1

Powered by Discuz! X5.0   © 2024-2025 闲社网·线报更新论坛·羊毛分享社区·http://xianshe.com

p2p_official_large
返回顶部