Skip to content

sdk/lib/foldertree

function addPageToFolderTree(
tree: FolderNode[],
folderId: string,
newPage: FolderNode): FolderNode[]

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:180

Adds a new page to the folder tree.

FolderNode[]

The root of the folder tree.

string

The ID of the parent folder.

FolderNode

The new page to add.

FolderNode[]

The updated folder tree


function findNodeById(tree: FolderNode[], id: string): null | FolderNode

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:160

Finds a node by its ID in the tree.

FolderNode[]

string

The ID of the node to find.

null | FolderNode

The node or null if not found.


function findNodeByPath(tree: FolderNode[], path: string[]): null | FolderNode

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:47

Finds a node in the tree that matches the given URL path.

FolderNode[]

The root of the folder tree.

string[]

The URL path to locate.

null | FolderNode

The matching node or null if not found.


function findNodesAlongPath(tree: FolderNode[], path: string[]): FolderNode[]

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:130

Finds all nodes along the path to a given URL.

FolderNode[]

The root of the folder tree.

string[]

The URL path to locate.

FolderNode[]

The nodes along the path.


function findNodesAlongPathToId(tree: FolderNode[], id: string): FolderNode[]

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:68

Finds all nodes along the path to a specific node by its ID.

FolderNode[]

The root of the folder tree.

string

The ID of the target node.

FolderNode[]

An array of nodes along the path or an empty array if the node is not found.


function generateFolderTree(folders: {
id: string;
name: string;
parent: null | string;
}[]): FolderNode[]

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:9

Builds a folder structure from the provided folder data.

{ id: string; name: string; parent: null | string; }[]

An array of folder data to build the folder structure from.

FolderNode[]

An array of folder nodes representing the folder structure.


function getFullPath(tree: FolderNode[], path: string[]): string[]

Defined in: studiocms/packages/studiocms/src/sdk/lib/foldertree.ts:99

Finds the full path to a node based on its URL.

FolderNode[]

The root of the folder tree.

string[]

The URL path to locate.

string[]

The full path as an array of node names.