Project Document Schema
Relevant source files
The following files were used as context for generating this wiki page:
- sanity/schemas/documents/project.ts
- sanity.types.ts
- sanity/schemas/objects/duration.ts (Inferred from project.ts usage and schema.json)
- sanity/schemas/objects/milestone.ts
- sanity/schemas/objects/timeline.ts (Inferred from project.ts usage and schema.json)
- schema.json
- sanity/lib/queries.ts
The Project Document Schema defines the data structure for showcase items within the personal website. It is implemented as a Sanity document type that captures comprehensive details about software projects, professional engagements, or personal works. This schema serves as the primary data model for individual project pages and the homepage showcase.
The schema is central to the site's content architecture, linking primary project metadata (like titles and slugs) with rich-text descriptions that include complex objects such as timelines and embedded images.
Sources: sanity/schemas/documents/project.ts, README.md:104-106
Core Data Model
The project document is a collection of fields ranging from basic strings to complex nested arrays. It utilizes Sanity's defineType and defineField helpers to enforce validation and UI behavior in the Studio.
Primary Fields
These fields represent the fundamental identity and SEO metadata for a project.
| Field | Type | Description | Constraints |
|---|---|---|---|
title | string | The primary name of the project. | Required |
slug | slug | Unique URL identifier generated from the title. | Required, Max 96 chars |
overview | array | Short summary for SEO meta tags and subheaders. | Required, Max 155 chars |
coverImage | image | Main visual asset used in lists and headers. | Required, Hotspot enabled |
Sources: sanity/schemas/documents/project.ts:11-64, schema.json:187-320
Metadata & Categorization
Additional attributes used to provide context and filtering for project entries.
- Duration: A custom object tracking the start and end dates of the project.
- Client: A simple string identifying the entity the project was built for.
- Site: A URL field for a live link to the project.
- Tags: An array of strings used for categorization, rendered with a "tags" layout in the editor.
Sources: sanity/schemas/documents/project.ts:65-90, sanity.types.ts:68-80
Rich Content Architecture
The description field is the most complex component of the Project schema. It uses Portable Text to allow editors to interleave standard text blocks with specialized data structures.
The diagram shows how the project description acts as a container for various content types, allowing for non-linear storytelling via timelines.
Sources: sanity/schemas/documents/project.ts:91-140, schema.json:341-550
Embedded Objects
The schema integrates several reusable object types to enhance the project presentation:
- Timeline: Captures a sequence of events. It contains an array of items, each consisting of a title and a list of
milestoneobjects. - Milestone: A specific event within a timeline, including its own
title,description,image,tags, andduration. - Duration: A simple object containing
startandenddate strings.
Sources: sanity/schemas/objects/milestone.ts:3-44, sanity.types.ts:21-46, schema.json:1-168
Data Retrieval and Implementation
Project data is retrieved from the Sanity Content Lake using GROQ queries. The primary query for a single project fetches all fields and flattens the slug for easier consumption in the Next.js frontend.
// sanity/lib/queries.ts:30-43
export const projectBySlugQuery = defineQuery(`
*[_type == "project" && slug.current == $slug][0] {
_id,
_type,
client,
coverImage,
description,
duration,
overview,
site,
"slug": slug.current,
tags,
title,
}
`)
Visual Relationship Schema
The following ER diagram illustrates the relationships between the Project document and its constituent parts.
The diagram depicts the one-to-one and one-to-many relationships defined within the schema types.
Sources: sanity/schemas/documents/project.ts:11-140, sanity.types.ts:51-118
Technical Specifications Summary
| Feature | Implementation Detail |
|---|---|
| Document Name | project |
| Icon | DocumentIcon from @sanity/icons |
| Validation | Custom rules for title, slug, and overview length. |
| Preview | Uses title and coverImage for Studio list views. |
| TypeScript Type | Project (Generated via Sanity TypeGen) |
Sources: sanity/schemas/documents/project.ts:4-10, sanity.types.ts:51-118, sanity.config.ts:34-43
Conclusion
The Project Document Schema provides a structured yet flexible framework for managing portfolio content. By combining strictly validated metadata with the extensibility of Portable Text and custom objects like Timelines, it enables the creation of detailed, media-rich project case studies. This schema is a core component of the project's content strategy, ensuring data consistency across the Sanity Studio and the Next.js frontend.