---
title: "file"
description: "Reads one file holding many entries."
url: "https://pitlane.tools/package/content/loaders/function/file"
---

# file

```ts
import { file } from "@pitlane/content/loaders";
```

```ts
function file(fileName, options?): ContentLoader;
```

Reads one file holding many entries.

Every entry is data rather than a document: a file of records has no body to render, so `render()` on one of these entries is a mistake and says so.

The file holds either an object whose keys are entry ids or an array of entries that each carry an `id`. `.json`, `.yaml`, and `.yml` parse without options; any other format needs `options.parser`, which turns the file's text into that object or array.

## Parameters

### fileName

`string`

### options?

#### parser?

(`text`: `string`) => `unknown`

## Returns

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

## See

[Content guide](https://pitlane.tools/guides/content.md)
