Skip to content
qino

Since 0.1.0

getFlatTree

Return every node in depth-first reading order.

Walks the tree and flattens it depth-first, so a section comes right before its children.

src/app/docs/[...slug]/page.tsx
const nodes = await docsTree.getFlatTree();
// introduction, guides, guides/setup, guides/deploy, faq

Signature

@qino/cms
tree.getFlatTree(): Promise<Array<TreeNode>>;

Parameters

None.

Returns

Promise<Array<TreeNode>> in pre-order. Each node still carries its own children.

Throws

The same walk errors as getTree.

Example

src/app/docs/[...slug]/page.tsx
export async function generateStaticParams() {
  const nodes = await docsTree.getFlatTree();
  return nodes.map((node) => ({ slug: node.slug.split("/") }));
}