Skip to content

MIGRATION: Set up Astro content collections with lesson singletons #41

@jt14den

Description

@jt14den

Goal

Set up Astro content collections to store each lesson as an individual JSON file (singleton pattern).

Context

See full migration plan: .github/MIGRATION_TO_KEYSTATIC.md

Currently lessons are fetched from Google Sheets. We're migrating to Git-based content with one file per lesson.

Tasks

  • Create src/content/ directory
  • Create src/content/config.ts with lesson schema
  • Define Zod schema for lesson validation (name, slug, description, url, etc.)
  • Configure content collection type as 'data' (JSON files)
  • Create placeholder lesson files for testing (2-3 examples)
  • Test content collection queries work
  • Update TypeScript types in src/types/lesson.ts to match schema
  • Document content collection structure in STUDENT_README.md

Content Structure

src/content/
├── config.ts              # Schema definition
└── lessons/               # One file per lesson
    ├── building-community.json
    ├── leadership-governance.json
    └── ... (56 total after migration)

Example Schema

import { defineCollection, z } from 'astro:content';

const lessons = defineCollection({
  type: 'data',
  schema: z.object({
    name: z.string(),
    slug: z.string(),
    description: z.string(),
    url: z.string().url(),
    learnerCategory: z.string(),
    educationalLevel: z.enum(['Beginner', 'Intermediate', 'Advanced']),
    ossRole: z.string().optional(),
    subTopic: z.string().optional(),
    timeRequired: z.string().optional(),
    keywords: z.array(z.string()).optional(),
    author: z.string().optional(),
    license: z.string().optional(),
  }),
});

export const collections = { lessons };

Acceptance Criteria

  • Content collections configured in src/content/config.ts
  • Zod schema includes all required lesson fields
  • Can query lessons using getCollection('lessons')
  • TypeScript validation works (build fails on invalid data)
  • At least 2-3 example lesson files created and validated

References

Time Estimate

3-4 hours

Dependencies

Can start independently, but works best after Keystatic setup (#36)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

In Progress

Relationships

None yet

Development

No branches or pull requests

Issue actions