Overview
The Sanity connector integrates with Sanity’s structured content platform, converting Skayle articles to Portable Text format. It supports:- Publishing to any Sanity document type
- Flexible field mapping for custom schemas
- Category, tag, and author synchronization via references
- Asset management for images
- Scheduled publishing
Prerequisites
Before connecting, ensure you have:- Sanity project with a dataset
- API token with write permissions
- Document type for blog posts/articles
- Reference types for categories, tags, and authors (optional)
Setup Guide
Step 1: Get Your Project Credentials
- Go to sanity.io/manage
- Select your project
- Note your Project ID (e.g.,
abc123xyz) - Note your Dataset name (usually
production)
Step 2: Create an API Token
- In your Sanity project, go to API → Tokens
- Click Add API token
- Name it (e.g., “Skayle Integration”)
- Select Editor permissions (or custom with write access)
- Click Save and copy the token
Step 3: Configure Field Mapping
Skayle needs to know how your Sanity schema maps to article fields:Step 4: Configure in Skayle
- Go to Settings → Connectors in Skayle
- Select Sanity as your connector type
- Enter your configuration:
| Field | Description | Example |
|---|---|---|
| Project ID | Your Sanity project ID | abc123xyz |
| Dataset | Dataset name | production |
| Token | API token | sk... |
| Document Type | Schema type for posts | post |
| Title Field | Field name for title | title |
| Slug Field | Field name for slug | slug.current |
| Content Field | Field name for body | body |
| Excerpt Field | Field name for excerpt | excerpt |
- Click Test Connection to verify
Example Sanity Schema
Here’s a recommended schema for blog posts that works well with Skayle:Content Formatting
Skayle converts BlockNote JSON to Sanity Portable Text format:Portable Text Structure
Supported Block Types
| BlockNote Type | Portable Text Style |
|---|---|
| Paragraph | normal |
| Heading 1 | h1 |
| Heading 2 | h2 |
| Heading 3 | h3 |
| Heading 4 | h4 |
| Heading 5 | h5 |
| Heading 6 | h6 |
| Bullet List | bullet |
| Numbered List | number |
| Blockquote | blockquote |
| Code | normal with code mark |
Marks (Inline Formatting)
| Format | Portable Text Mark |
|---|---|
| Bold | strong |
| Italic | em |
| Underline | underline |
| Strikethrough | strike-through |
| Code | code |
| Link | link with href |
Taxonomy Mapping
References
Sanity uses references for relationships. When publishing:- Skayle looks up the category/tag/author in the mapping table
- Creates a Sanity reference:
{ _type: "reference", _ref: "sanity-doc-id" } - Assigns references to the appropriate fields
Syncing Taxonomies
- Import from Sanity
- Export to Sanity
Fetches documents of your taxonomy types and creates Skayle equivalents:
Image Handling
The connector handles images in two ways:External URLs
If your schema accepts URL strings, images are passed as URLs:Sanity Assets
For proper Sanity image assets, the connector can upload images:Asset upload requires additional API calls and may increase publishing time.
Troubleshooting
Connection Issues
401 Unauthorized
401 Unauthorized
Project not found
Project not found
- Verify Project ID is correct
- Check dataset name matches exactly
- Ensure project is active
Schema validation errors
Schema validation errors
- Verify field mapping matches your schema
- Check required fields are mapped
- Ensure field types are compatible
Publishing Issues
Document not created
Document not created
- Check Sanity Studio for draft documents
- Verify document type exists in schema
- Check for validation errors in Sanity
References not working
References not working
- Ensure taxonomy documents exist in Sanity
- Run taxonomy sync first
- Verify reference field types match
Content not rendering
Content not rendering
- Verify your frontend handles Portable Text
- Check block types are supported
- Use
@portabletext/reactfor rendering
Best Practices
- Use consistent schemas: Keep your Sanity schema aligned with Skayle’s field mapping
- Sync taxonomies first: Always sync taxonomies before publishing articles
- Test with drafts: Use Sanity’s draft system to preview before publishing
- Monitor mutations: Use Sanity’s history to track changes from Skayle
- Backup regularly: Export your dataset periodically