Skip to main content

Words Schema

The words schema defines the structure for all Guatemalan slang entries in the Chapinismos dictionary. It uses Zod for runtime validation and TypeScript type inference.

Schema Definition

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

const wordsSchema = z.object({
  word: z.string(),
  meaning: z.string(),
  examples: z.array(z.string()),
  category: z.enum([
    "sustantivo", "noun",
    "verbo", "verb",
    "adjetivo", "adjective",
    "adverbio", "adverb",
    "expresión", "expression",
    "interjección", "interjection",
    "modismo", "idiom",
  ]),
  region: z.string().optional(),
  synonyms: z.array(z.string()).optional(),
  relatedWords: z.array(z.string()).optional(),
  featured: z.boolean().optional(),
});

Collections

Two collections use this schema:
  • words-es - Spanish language entries
  • words-en - English language entries
export const collections = {
  "words-es": defineCollection({ type: "content", schema: wordsSchema }),
  "words-en": defineCollection({ type: "content", schema: wordsSchema }),
};

Fields

word

word
string
required
The Guatemalan word or expression being defined.Examples:
  • "Chucho"
  • "A huevo"
  • "Está cabrón"
  • "Puchica"

meaning

meaning
string
required
The definition or explanation of the word’s meaning in the target language.Spanish example:
meaning: "Perro, especialmente uno callejero o de raza mestiza"
English example:
meaning: "Dog, especially a street dog or mixed breed"

examples

examples
string[]
required
Array of example sentences showing the word used in context. Must contain at least one example.Usage:
examples:
  - "Mirá ese chucho que anda por ahí"
  - "Mi chucho se llama Firulais"

category

category
enum
required
Grammatical category of the word. Accepts both Spanish and English category names.Accepted values:
  • "sustantivo" / "noun" - Nouns
  • "verbo" / "verb" - Verbs
  • "adjetivo" / "adjective" - Adjectives
  • "adverbio" / "adverb" - Adverbs
  • "expresión" / "expression" - Expressions/phrases
  • "interjección" / "interjection" - Interjections
  • "modismo" / "idiom" - Idioms
Categories have associated colors defined in @/utils/categoryColors.ts for visual consistency across the app.

region

region
string
default:"undefined"
Optional field specifying the region or department of Guatemala where the word is primarily used.Examples:
region: "Guatemala City"
region: "Antigua"
region: "Quetzaltenango"
region: "Costa Sur"

synonyms

synonyms
string[]
default:"undefined"
Optional array of synonymous words or expressions.Usage:
synonyms:
  - "can"
  - "lomito"
  - "firulais"

relatedWords

Optional array of semantically related words that aren’t direct synonyms.Usage:
relatedWords:
  - "gato"
  - "mascota"
  - "animal"
Whether this word should appear in the “Featured Words” section on the homepage.Usage:
featured: true

Complete Example

---
word: "Chucho"
meaning: "Perro, especialmente uno callejero o de raza mestiza. Es una forma cariñosa y común de referirse a los perros en Guatemala."
examples:
  - "Mirá ese chucho que anda por ahí"
  - "Mi chucho se llama Firulais"
  - "Ese chucho siempre me ladra cuando paso"
category: "sustantivo"
region: "Nacional"
synonyms:
  - "can"
  - "lomito"
  - "firulais"
relatedWords:
  - "gato"
  - "mascota"
featured: true
---

Contenido adicional sobre la palabra (opcional)

TypeScript Types

When using the schema in TypeScript, Astro automatically infers types:
import { getCollection, type CollectionEntry } from 'astro:content';

// Inferred type from schema
type WordEntry = CollectionEntry<'words-es'>;

// Access to data fields
interface WordData {
  word: string;
  meaning: string;
  examples: string[];
  category: "sustantivo" | "verbo" | "adjetivo" | "adverbio" | 
            "expresión" | "interjección" | "modismo" |
            "noun" | "verb" | "adjective" | "adverb" | 
            "expression" | "interjection" | "idiom";
  region?: string;
  synonyms?: string[];
  relatedWords?: string[];
  featured?: boolean;
}

// Usage in component
const allWords = await getCollection('words-es');
const word = allWords[0].data; // Type: WordData

Querying Words

import { getCollection } from 'astro:content';

const wordsEs = await getCollection('words-es');
const wordsEn = await getCollection('words-en');

File Structure

Content files should be placed in:
  • src/content/words-es/*.md - Spanish entries
  • src/content/words-en/*.md - English entries
src/content/
├── words-es/
│   ├── chucho.md
│   ├── a-huevo.md
│   ├── chapin.md
│   └── ...
└── words-en/
    ├── chucho.md
    ├── a-huevo.md
    ├── chapin.md
    └── ...
Astro automatically generates slugs from file names. For example, chucho.md becomes accessible at /palabras/chucho/

Validation

The schema provides automatic validation:
---
word: "Puchica"
meaning: "Interjección de sorpresa"
examples:
  - "¡Puchica qué calor!"
category: "interjección"
---

  • Category Colors: @/utils/categoryColors - Get colors for category badges
  • Slug Generation: @/utils/slug - Generate URL-safe slugs from words
  • i18n: @/utils/i18n - Translation utilities for multilingual content

Schema Reference

Location: src/content/config.ts
import { defineCollection, z } from "astro:content";

const wordsSchema = z.object({
  word: z.string(),
  meaning: z.string(),
  examples: z.array(z.string()),
  category: z.enum([
    "sustantivo", "noun",
    "verbo", "verb",
    "adjetivo", "adjective",
    "adverbio", "adverb",
    "expresión", "expression",
    "interjección", "interjection",
    "modismo", "idiom",
  ]),
  region: z.string().optional(),
  synonyms: z.array(z.string()).optional(),
  relatedWords: z.array(z.string()).optional(),
  featured: z.boolean().optional(),
});

export const collections = {
  "words-es": defineCollection({ type: "content", schema: wordsSchema }),
  "words-en": defineCollection({ type: "content", schema: wordsSchema }),
};

Build docs developers (and LLMs) love