---
title: "TreeNode"
description: "The structural node returned by tree getters."
canonical: "https://www.qino.works/docs/api/types/tree-node"
---

# TreeNode

> The structural node returned by tree getters.

`getTree`, `getFlatTree`, `getAncestorNodes`, `getNextNode`, and `getPreviousNode` return nodes, not entries.

```ts title="@qino/cms"
import type { TreeNode } from "@qino/cms";

type TreeNode = {
  slug: string;
  title: string;
  fileName: string;
  filePath: string;
  children: Array<TreeNode>;
};
```

## Fields

| Field      | Description                                            |
| ---------- | ------------------------------------------------------ |
| `slug`     | Slash-joined path minus the extension                  |
| `title`    | Value of the tree's `titleField` in that file          |
| `fileName` | Basename with extension                                |
| `filePath` | Absolute path on disk                                  |
| `children` | Ordered child nodes. Always an array, empty for leaves |

A node has no schema fields and no augment output. Read the content with [getEntry](https://www.qino.works/docs/api/tree/get-entry).

## Example

```tsx title="src/app/docs/docs-sidebar.tsx"
import type { TreeNode } from "@qino/cms";

function Sidebar({ nodes }: { nodes: Array<TreeNode> }) {
  return (
    <ul>
      {nodes.map((node) => (
        <li key={node.slug}>
          {node.title}
          {node.children.length > 0 && <Sidebar nodes={node.children} />}
        </li>
      ))}
    </ul>
  );
}
```
