# LoadContext

What a loader's load receives.

> Every page: https://tomekit.aayush.cv/llms.txt

Defined in: [index.ts:110](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/index.ts#L110)

What a loader's `load` receives.

## Example

```ts
const pages: Loader = {
  load: async ({ collection, root }) => ({
    entries: JSON.parse(await readFile(path.join(root, `data/${collection}.json`), "utf-8")),
  }),
};
```

## Properties

### collection

```ts
collection: string;
```

Defined in: [index.ts:112](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/index.ts#L112)

The name of the collection, eg `posts`.

***

### dev

```ts
dev: boolean;
```

Defined in: [index.ts:114](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/index.ts#L114)

Whether the Vite dev server is running, as opposed to a build.

***

### root

```ts
root: string;
```

Defined in: [index.ts:116](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/index.ts#L116)

The project root, as an absolute path.

***

### watch

```ts
watch: (patterns: Glob | readonly Glob[]) => void;
```

Defined in: [index.ts:134](https://github.com/aayushbtw/tomekit/blob/main/packages/tomekit/src/index.ts#L134)

Reruns `load` in dev when a file matching these globs changes. Patterns are relative to the project root; start one with `!` to leave files out. A `!` pattern only leaves out files from the same call, so loaders that call each other's `load` keep their own globs. Without a call, `load` reruns only when the config changes.

```ts
const authors: Loader = {
  load: async ({ root, watch }) => {
    watch("data/authors.json");
    return { entries: JSON.parse(await readFile(path.join(root, "data/authors.json"), "utf-8")) };
  },
};
```
