Skip to content

Search the guides, deployment pages, and API reference.

LoaderContext

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

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

Properties

collection

collection: string;

root

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

store: object;

set()

set(entry): void;

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

Parameters
entry

LoadedEntry

Returns

void

Methods

parseData()

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>