> ## Documentation Index
> Fetch the complete documentation index at: https://dos.dzaleka.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resource Model

> Complete schema documentation for the Resource model in Dzaleka Online Services

## Overview

The Resource model represents documents, guides, reports, and educational materials available to the Dzaleka community. Resources can include PDFs, links to external content, educational materials, and informational documents.

## Schema Definition

The Resource model is defined using Zod schema validation in `src/content.config.ts:78-94`.

### TypeScript Type

```typescript theme={null}
type Resource = {
  title: string;
  description: string;
  category: string;
  featured?: boolean;
  date: Date;
  author?: string;
  thumbnail?: string;
  fileType?: string;
  fileSize?: string;
  downloadUrl?: string;
  resourceUrl?: string;
  lastUpdated?: Date;
  languages?: string[];
  tags?: string[];
};
```

## Fields

### Core Fields

<ResponseField name="title" type="string" required>
  The title of the resource document or material.
</ResponseField>

<ResponseField name="description" type="string" required>
  A clear description of what the resource contains and its purpose.
</ResponseField>

<ResponseField name="category" type="string" required>
  The category of resource (e.g., "Situation Reports / Updates", "Educational Materials", "Legal Documents", "Community Guides").
</ResponseField>

<ResponseField name="date" type="Date" required>
  The publication or creation date of the resource.
</ResponseField>

<ResponseField name="author" type="string">
  The author or organization that created the resource (e.g., "UNHCR Malawi").
</ResponseField>

<ResponseField name="featured" type="boolean">
  Whether this resource should be featured prominently on the platform.
</ResponseField>

<ResponseField name="thumbnail" type="string">
  Path or URL to a thumbnail image representing the resource.
</ResponseField>

<ResponseField name="tags" type="string[]">
  Array of tags for categorization and searchability.
</ResponseField>

### File Information

<ResponseField name="fileType" type="string">
  The type of file (e.g., "pdf", "docx", "video", "link").
</ResponseField>

<ResponseField name="fileSize" type="string">
  Human-readable file size (e.g., "748.24 KB", "2.5 MB").
</ResponseField>

<ResponseField name="downloadUrl" type="string">
  Direct download URL for the resource file. Use this for downloadable files like PDFs.
</ResponseField>

<ResponseField name="resourceUrl" type="string">
  URL to view or access the resource online (not necessarily for download).
</ResponseField>

### Metadata

<ResponseField name="lastUpdated" type="Date">
  When the resource was last updated or modified.
</ResponseField>

<ResponseField name="languages" type="string[]">
  Array of languages the resource is available in (e.g., \["English", "French", "Swahili"]).
</ResponseField>

## Example

Here's a complete example of a Resource object for a UNHCR report:

```json theme={null}
{
  "title": "Banking services in Dzaleka Refugee Camp",
  "description": "New Finance Bank opened its branch of service in Dzaleka Refugee Camp on 12 April 2018.",
  "date": "2019-03-01T00:00:00.000Z",
  "category": "Situation Reports / Updates",
  "fileType": "pdf",
  "resourceUrl": "https://data.unhcr.org/en/documents/details/68623",
  "downloadUrl": "https://data.unhcr.org/en/documents/download/68623",
  "fileSize": "748.24 KB",
  "lastUpdated": "2024-12-27T00:00:00.000Z",
  "languages": ["English"],
  "featured": false,
  "author": "UNHCR Malawi"
}
```

## Usage in Content

Resources are stored as Markdown files in `src/content/resources/` with YAML frontmatter:

```markdown theme={null}
---
title: Banking services in Dzaleka Refugee Camp
description: New Finance Bank opened its branch of service in Dzaleka Refugee Camp on 12 April 2018.
date: 2019-03-01
category: Situation Reports / Updates
fileType: pdf
resourceUrl: https://data.unhcr.org/en/documents/details/68623
downloadUrl: 'https://data.unhcr.org/en/documents/download/68623'
fileSize: '748.24 KB'
lastUpdated: 2024-12-27
languages: ['English']
featured: false
author: UNHCR Malawi
---

## About Report

New Finance Bank opened its branch of service in Dzaleka Refugee Camp on 12 April 2018.
```

## Resource Types

Resources can take several forms:

### Downloadable Files

Use `downloadUrl` for files that users can download:

* PDF documents
* Word documents
* Spreadsheets
* Images
* Archive files

```json theme={null}
{
  "fileType": "pdf",
  "downloadUrl": "https://example.com/document.pdf",
  "fileSize": "2.3 MB"
}
```

### External Links

Use `resourceUrl` for resources hosted elsewhere:

* Web pages
* Online tools
* External databases
* Video platforms

```json theme={null}
{
  "resourceUrl": "https://example.com/resource-page",
  "fileType": "link"
}
```

### Hybrid Resources

Some resources have both viewing and download options:

```json theme={null}
{
  "resourceUrl": "https://data.unhcr.org/en/documents/details/68623",
  "downloadUrl": "https://data.unhcr.org/en/documents/download/68623",
  "fileType": "pdf",
  "fileSize": "748.24 KB"
}
```

## Validation Rules

* `title`, `description`, `category`, and `date` are required fields
* At least one of `downloadUrl` or `resourceUrl` should be provided for the resource to be accessible
* `date` must be a valid Date object or ISO 8601 string
* `languages` should use standardized language names (e.g., "English", not "EN")
* `fileSize` should be human-readable (e.g., "1.5 MB" rather than "1500000")
* URLs should be complete and include protocol (https\://)

## Categories

Common resource categories include:

* **Situation Reports / Updates** - Current information about camp conditions and changes
* **Educational Materials** - Learning resources and guides
* **Legal Documents** - Rights, policies, and legal information
* **Community Guides** - How-to guides for community members
* **Health Resources** - Medical and health-related information
* **Business Resources** - Entrepreneurship and business guides
* **Cultural Materials** - Art, history, and cultural documentation

## Multilingual Support

The `languages` field allows resources to indicate availability in multiple languages:

```json theme={null}
{
  "title": "Community Guide to Services",
  "languages": ["English", "French", "Swahili", "Kinyarwanda"]
}
```

This helps users filter and find resources in their preferred language.
