Scripts for seeding Learning Management System (LMS) content to Sanity CMS.
Tests Sanity connection and validates write access. Outputs schema definitions for Sanity Studio.
npx tsx sanity/sanity-install-schema.tsSeeds course content from JSON files to Sanity CMS.
# Seed a single course
npx tsx sanity/seed-course-to-sanity.ts <course-slug>
# Seed all courses
npx tsx sanity/seed-course-to-sanity.ts --allCreate a .env file with:
SANITY_PROJECT_ID=your-project-id
SANITY_DATASET=production
SANITY_API_TOKEN=your-api-token- Go to sanity.io/manage
- Select your project (or create one)
- Project ID is in the URL or project settings
- Go to API → Tokens → Add API token
- Create a token with "Editor" permissions
The scripts create the following document types in Sanity:
| Type | Description |
|---|---|
course |
Learning course with modules |
module |
Course module containing lessons |
lesson |
Individual lesson with content and quizzes |
question |
Quiz question with answers |
answer |
Quiz answer option |
contentItem |
Content item for content groups |
learningPath |
Learning path containing multiple courses |
certificate |
Completion certificate for learning paths |
npm install @sanity/client dotenv