Back to Sanity

Sanity Examples

examples/README.md

5.31.14.1 KB
Original Source

Sanity Examples

This directory contains comprehensive examples and reference implementations for various Sanity features and integrations. Whether you're building your first Sanity project or exploring advanced functionality, these examples provide practical code you can reference and adapt.

šŸ“ Directory Structure

text
examples/
ā”œā”€ā”€ functions/            # Sanity Functions examples
└── studios/              # Studio configuration examples

šŸ”§ Functions

The functions/ directory contains examples of Sanity Functions - serverless functions that run in Sanity's cloud environment. Each function example includes:

  • Implementation code (index.ts) - The actual function logic
  • Configuration (package.json) - Dependencies and blueprint resource configuration
  • Test data (document.json) - Sample data for testing
  • Documentation (README.md) - Usage instructions and explanations

Key Files

  • sanity.blueprint.ts - Automatically discovers and configures all function examples for easy testing
  • package.json - Shared dependencies for all function examples
  • vite.config.js - Build configuration for bundling functions

Available Function Examples

  • auto-changelog - AI-powered automatic changelog generation for document updates
  • auto-tag - AI-powered automatic tagging for blog posts
  • first-published - Automatic timestamp tracking for first publication
  • slack-notify - Automatic Slack notifications when content is published
  • brand-voice-validator - AI-powered content analysis and improvement suggestions
  • capture-tone-of-voice - AI-powered tone of voice analysis and capture for content
  • algolia-document-sync - Automatically sync documents into an Algolia search index
  • auto-summary - AI-Powered summary generation for editorial content
  • stale-content-digest - Scheduled function that finds stale documents, has the Content Agent review them, and posts a weekly digest to Slack

šŸŽØ Studios

The studios/ directory contains complete Sanity Studio configurations showcasing different use cases:

Each studio example demonstrates schema design, custom components, and workflow configurations.

šŸš€ Getting Started

  1. Browse the examples - Each directory contains detailed README files explaining the implementation
  2. Copy reference code - Use the examples as starting points for your own projects
  3. Test locally - Many examples include setup instructions for local development
  4. Adapt and extend - Modify the examples to fit your specific use case

šŸ“– Learning Resources

For comprehensive documentation and tutorials, visit:

šŸ’” Contributing

Found a bug or have an idea for a new example? Contributions are welcome! Please check the project's contribution guidelines before submitting pull requests.


Note: These examples are part of the Sanity monorepo and are designed for reference and learning. For production use, always review and adapt the code to meet your specific requirements and security standards.