Content Collections
Relevant source files
The following files were used as context for generating this wiki page:
Content Collections manage structured data and Markdown content for the website. The system separates content storage in src/content/ from logical processing and type validation. It uses Astro loaders to fetch data and Zod schemas to enforce strict data structures for pages and resume entries.
Sources: AGENTS.md:76-80, src/content.config.ts:1-30
Architecture and Data Flow
The project organizes content into two primary collections: pages and resume. The content.config.ts file defines how these collections are loaded and validated. Markdown files serve the site's pages, while YAML files store resume data.
The diagram shows the flow from physical file storage through the central configuration to schema validation.
Sources: src/content.config.ts:7-25, src/configs/content.ts:1-12
Collection Definitions
The system defines collection metadata in a central configuration and applies loaders in the main content configuration file.
| Collection | Source Path | File Pattern | Loader Type |
|---|---|---|---|
pages | src/content/pages | **/[^_]*.{md,mdx} | glob (Markdown) |
resume | src/content/resume | **/[^_]*.yaml | glob (YAML) |
Sources: src/configs/content.ts:1-12, src/content.config.ts:10-25
Pages Collection
The pages collection handles Markdown and MDX files. It includes a schema for frontmatter validation, including SEO metadata and ordering.
- Filter Logic: Filters exclude drafts by default. You can also include specific pages by ID or directory.
- Sorting: Supports sorting by
orderfield or alphabetically bytitle. - SEO Resolution: Merges SEO overrides with frontmatter and rendered HTML content.
Sources: src/features/pages/pages.utils.ts:35-74, src/content.config.ts:10-16
Resume Collection
The resume collection processes YAML files to build a structured professional profile.
- Data Assembly: The system groups individual YAML files into sections like
basics,experience, andskills. - Sorting Logic: Experience items sort by date, placing current roles (where
endDateis "present" or null) first. - Skills Structure: Organizes skills into categories with associated item lists.
Sources: src/features/resume/resume.utils.ts:1-50, src/content/resume/skills.yaml:1-40
Schema Validation
The project uses Zod schemas to ensure data integrity across all content files.
Resume Schema Components
The resume schema validates multiple entry shapes using a union of specific object types.
The diagram represents the primary data structures validated within the resume collection.
Sources: src/features/resume/resume.schema.ts:25-95
Schema Constraints
The validation system enforces specific formats for critical data points:
- Dates: Must follow
YYYY-MMorYYYY-MM-DDpatterns. - End Dates: Accepts valid date strings, null, or the case-insensitive string "present".
- Strictness: Community items use strict validation to prevent overlapping with award items during union resolution.
Sources: src/features/resume/resume.schema.ts:6-23, src/features/resume/resume.schema.ts:62-68
Utility Functions
Standard helpers manage the processing of collection data after loading.
buildPagesFilter(options): Creates a predicate function to filter page entries based on draft status and inclusion lists.resolvePageSeo(page): Prioritizes SEO titles and descriptions over standard frontmatter and body content.assembleResumeData(entries): Transforms a flat array of collection entries into a nested resume object grouped by section.parseContentId(id): Splits file IDs into sections and item identifiers for nested content structures.
Sources: src/features/pages/pages.utils.ts:51-74, src/features/resume/resume.utils.ts:1-25, src/utils/content.ts:1-20
Conclusion
Content Collections provide a type-safe bridge between static files and the Astro frontend. By using dedicated schemas and utility functions for each domain (Pages and Resume), the system ensures that content remains structured, searchable, and valid throughout the build process.