## Documentation index

This index lists every available documentation page and its Markdown source.

- [Documentation](https://veta.varavel.com/docs/index.md)
  - [Getting Started](https://veta.varavel.com/docs/getting-started/index.md)
  - [Installation](https://veta.varavel.com/docs/installation/index.md)
  - [Guides](https://veta.varavel.com/docs/guides/index.md)
    - [Project Structure](https://veta.varavel.com/docs/guides/project-structure/index.md)
    - [Configuration](https://veta.varavel.com/docs/guides/configuration/index.md)
    - [Pages](https://veta.varavel.com/docs/guides/pages/index.md)
    - [Data](https://veta.varavel.com/docs/guides/data/index.md)
    - [Markdown](https://veta.varavel.com/docs/guides/markdown/index.md)
    - [Templates](https://veta.varavel.com/docs/guides/templates/index.md)
    - [Components](https://veta.varavel.com/docs/guides/components/index.md)
    - [Filters](https://veta.varavel.com/docs/guides/filters/index.md)
    - [Assets And Tailwind CSS](https://veta.varavel.com/docs/guides/assets-and-tailwind/index.md)
    - [Themes](https://veta.varavel.com/docs/guides/themes/index.md)
    - [Development Server](https://veta.varavel.com/docs/guides/development-server/index.md)
    - [Build And Output](https://veta.varavel.com/docs/guides/build-and-output/index.md)
    - [Deployment](https://veta.varavel.com/docs/guides/deployment/index.md)
  - [Reference](https://veta.varavel.com/docs/reference/index.md)
    - [CLI Reference](https://veta.varavel.com/docs/reference/cli/index.md)
    - [Config Reference](https://veta.varavel.com/docs/reference/config/index.md)
    - [Page Generators Reference](https://veta.varavel.com/docs/reference/page-generators/index.md)
    - [Template Context Reference](https://veta.varavel.com/docs/reference/template-context/index.md)
    - [Troubleshooting](https://veta.varavel.com/docs/reference/troubleshooting/index.md)
  - [API](https://veta.varavel.com/docs/api/index.md)
    - [JavaScript API](https://veta.varavel.com/docs/api/javascript/index.md)
    - [File API](https://veta.varavel.com/docs/api/files/index.md)
    - [HTTP Client](https://veta.varavel.com/docs/api/http-client/index.md)
    - [Parse API](https://veta.varavel.com/docs/api/parse/index.md)
    - [Template Functions](https://veta.varavel.com/docs/api/template-functions/index.md)
    - [Environment And Console](https://veta.varavel.com/docs/api/environment-and-console/index.md)
    - [Markdown Frontmatter](https://veta.varavel.com/docs/api/frontmatter/index.md)


## Documentation content

The documentation for the current page follows, reproduced verbatim.


# File API

The file API is available as `files` in JavaScript context objects.

```js
export default function({ files }) {
  return files.listFiles("content/**/*.md");
}
```

All paths are relative to the project root. Absolute paths and `..` path traversal are rejected.

## `files.listFiles(pattern)`

Returns sorted project-relative file paths matching a glob pattern.

```js
const posts = files.listFiles("content/posts/**/*.md");
```

Use `files.listFiles(".")` to list every file in the project. Empty patterns are rejected.

## `files.readFile(path)`

Reads a file as a UTF-8 string.

```js
const robots = files.readFile("public/robots.txt");
const site = parse.json(files.readFile("data/site.json"));
const { frontmatter, html } = parse.markdown(
  files.readFile("content/posts/hello.md"),
);
const content = parse.renderComponents(html);
```

`files.readFile` performs no parsing or rendering. In this example, `frontmatter` contains metadata, `html` is the rendered Markdown body, and `content` is the result of explicitly resolving registered components. See [Parse API](/docs/api/parse/) and [Frontmatter](/docs/api/frontmatter/) for details.

## `files.toPermalink(path, options)`

Converts a project-relative path into a pretty permalink.

```js
files.toPermalink("content/posts/hello.md", { stripPrefix: "content" });
// "/posts/hello/"
```

If the source file is an `index` file, the last segment is removed:

```js
files.toPermalink("content/docs/index.md", { stripPrefix: "content" });
// "/docs/"
```

Options:

```js
{
  stripPrefix: "content";
}
```

`stripPrefix` is optional. When present, Veta removes it as a complete path segment before generating the permalink. The source path must have that prefix.

## Security Rules

The file API rejects:

- empty file paths
- absolute paths
- Windows drive paths
- paths containing `..`
- symlink escapes outside the configured root

This keeps JavaScript file access confined to the project root.
