---
title: "LoaderContext"
description: "What a loader is handed to read its source and validate what it found."
url: "https://pitlane.tools/package/content/interface/LoaderContext"
---

# LoaderContext

```ts
import type { LoaderContext } from "@pitlane/content";
```

What a loader is handed to read its source and validate what it found.

## Properties

### collection

```ts
collection: string;
```

---

### root

```ts
root: string;
```

The project root a relative path resolves against.

`process.cwd()` at runtime, and the Vite root under `contentLayer()`, which is what keeps a collection pointing at the same files when the build runs from somewhere else.

---

### store

```ts
store: object;
```

#### set()

```ts
set(entry): void;
```

Adds one entry to the collection. An id written twice throws rather than merging.

##### Parameters

###### entry

[`LoadedEntry`](https://pitlane.tools/package/content/interface/LoadedEntry.md)

##### Returns

`void`

## Methods

### parseData()

```ts
parseData<D>(input): Promise<D>;
```

Validates one entry's data against the collection's schema and resolves to the parsed value; rejects naming the entry when it does not conform. Pass its result to `store.set`, never the raw data.

#### Type Parameters

##### D

`D`

#### Parameters

##### input

###### data

`unknown`

###### filePath?

`string`

###### id

`string`

#### Returns

`Promise`\<`D`>
