@kovaldev/shelter-sanity-types
v0.1.14
Published
This package contains automatically generated TypeScript types for the Sanity CMS schema used in the shelter project.
Downloads
37
Readme
@kovaldev/shelter-sanity-types
This package contains automatically generated TypeScript types for the Sanity CMS schema used in the shelter project.
Installation
npm install @kovaldev/shelter-sanity-typesUsage
import type {SanityDocument, SanityImageAsset} from '@kovaldev/shelter-sanity-types'
// Use the types in your components
interface MyComponentProps {
document: SanityDocument
image: SanityImageAsset
}Auto-updates
This package is automatically updated and published whenever the Sanity schema changes. The types are generated from:
schemaTypes/**- All schema type definitionsschema.json- The compiled schemasanity.config.*- Sanity configuration files
Development
To generate types locally, run from the root of the project:
npm run gen:typesThis will update the sanity.types.ts file in this package.
TypeScript Integration
The generated types in this package provide full TypeScript support for your Sanity content:
import type { Event, Page, Service } from '@kovaldev/shelter-sanity-types'
// Your content will be properly typed
interface ContentResponse {
events: Event[]
pages: Page[]
services: Service[]
}
// Use the types for your components
interface EventCardProps {
event: Event
}
const EventCard: React.FC<EventCardProps> = ({ event }) => {
return (
<div>
<h3>{event.title}</h3>
<p>{event.description}</p>
{/* TypeScript will provide autocomplete and type checking */}
</div>
)
}Benefits
- Type-safe: Full TypeScript integration with generated types
- Auto-updating: Types are automatically generated from your schema
- Comprehensive: Covers all your Sanity schema types
- Performance: No runtime overhead, compile-time type checking only
