sdk/lib/foldertree
Functions
'Read the “', Functions, '” section'addPageToFolderTree()
'Read the “', addPageToFolderTree(), '” section'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.
Parameters
'Read the “', Parameters, '” section'The root of the folder tree.
string
The ID of the parent folder.
The new page to add.
The updated folder tree
findNodeById()
'Read the “', findNodeById(), '” section'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.
Parameters
'Read the “', Parameters, '” section'string
The ID of the node to find.
null
| FolderNode
The node or null if not found.
findNodeByPath()
'Read the “', findNodeByPath(), '” section'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.
Parameters
'Read the “', Parameters, '” section'The root of the folder tree.
string
[]
The URL path to locate.
null
| FolderNode
The matching node or null if not found.
findNodesAlongPath()
'Read the “', findNodesAlongPath(), '” section'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.
Parameters
'Read the “', Parameters, '” section'The root of the folder tree.
string
[]
The URL path to locate.
The nodes along the path.
findNodesAlongPathToId()
'Read the “', findNodesAlongPathToId(), '” section'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.
Parameters
'Read the “', Parameters, '” section'The root of the folder tree.
string
The ID of the target node.
An array of nodes along the path or an empty array if the node is not found.
generateFolderTree()
'Read the “', generateFolderTree(), '” section'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.
Parameters
'Read the “', Parameters, '” section'{
id
: string
;
name
: string
;
parent
: null
| string
;
}[]
An array of folder data to build the folder structure from.
An array of folder nodes representing the folder structure.
getFullPath()
'Read the “', getFullPath(), '” section'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.
Parameters
'Read the “', Parameters, '” section'The root of the folder tree.
string
[]
The URL path to locate.
string
[]
The full path as an array of node names.