Skip to content
qino

Since 0.1.0

TreeNode

The structural node returned by tree getters.

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

@qino/cms
import type { TreeNode } from "@qino/cms";

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

Fields

FieldDescription
slugSlash-joined path minus the extension
titleValue of the tree's titleField in that file
fileNameBasename with extension
filePathAbsolute path on disk
childrenOrdered child nodes. Always an array, empty for leaves

A node has no schema fields and no augment output. Read the content with getEntry.

Example

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>
  );
}