Your activities are now connected to Sanity CMS! Here's how to use it:
cd sanity
npm run devThis will start Sanity Studio (usually at http://localhost:3333)
Alternatively, start your Next.js app and go to:
http://localhost:3000/studio
- Title: Activity name (e.g., "Summer School")
- Slug: URL-friendly identifier (auto-generated from title, click "Generate")
- Short Description: Brief summary (max 200 chars)
- Date: Display date (e.g., "Summer 2024", "March 2024")
- Main Image: Primary activity image
- Overview: Detailed description for detail page
- Details: Additional details (fallback for overview)
- Location: Where the activity took place
- Objectives: List of activity goals
- Highlights: Key features (title + description pairs)
- Statistics: Numbers (value + label, e.g., "80+ Participants")
- Organizers: List of organizing bodies
- Gallery: Additional images for the detail page
- Fetches all activities from Sanity using
getStaticProps - Falls back to default activities if Sanity is empty
- Displays cards with spotlight and canvas reveal effects
- Automatically uses Sanity images with optimization
- Fetches specific activity by slug
- Uses ISR (Incremental Static Regeneration) - revalidates every 60 seconds
- Falls back to static data if activity not found
- Displays full activity details with gallery
Sanity Studio → Create/Edit Activity → Save
↓
Next.js fetches data via Sanity client
↓
Pages regenerate every 60 seconds (ISR)
↓
Users see updated content
Images are automatically optimized using Sanity's image URL builder:
- Listing cards: 300x300px
- Detail header: 800x600px
- Gallery images: 600x400px
- Go to Sanity Studio
- Click "Activity" → "Create"
- Fill in:
- Title: "National Robotics Weekend"
- Click "Generate" for slug
- Short Description: "Annual robotics competition"
- Date: "March 2024"
- Upload Main Image
- Add Overview text
- Add Objectives (click + to add items):
- "Host premier robotics competition"
- "Encourage innovation"
- Add Highlights (click + to add objects):
- Title: "Line Following", Description: "Autonomous navigation challenge"
- Add Statistics:
- Value: "200+", Label: "Participants"
- Add Organizers: "IEEE INSAT RAS"
- Upload Gallery images
- Click "Publish"
- View on your website at
/activities/national-robotics-weekend
- Make sure Sanity Studio is published (not just saved as draft)
- Wait 60 seconds for ISR to pick up changes
- Check console for any fetch errors
- Verify images are uploaded in Sanity
- Check that
projectIdanddatasetare correct insanity/env.js - Ensure images are published, not drafts
Change revalidate: 60 to a lower number in both:
pages/activities.jspages/activities/[slug].js
- ✅
sanity/schemaTypes/activities.js- Enhanced schema - ✅
pages/activities.js- Added getStaticProps to fetch activities - ✅
pages/activities/[slug].js- Added getStaticPaths and getStaticProps - ✅
components/activitiesnew/activitiesnew.js- Accepts activities prop - ✅
components/activitydetail/activitydetail.js- Handles Sanity images
- Start Sanity Studio and create your first activity
- Test the flow by creating an activity and viewing it on the site
- Customize the schema if you need additional fields
- Deploy both Next.js app and Sanity Studio to production
cd sanity
npm run deployYour activities will automatically fetch from Sanity in production!
Need help? Check the Sanity docs: https://www.sanity.io/docs