Navigation Tree API
Last modified by Pierre Jeanjean on 2026/02/05 17:22
Content
Reference
A NavigationTreeSource is a component that offers two methods:
import type { DocumentReference } from '@xwiki/platform-model-api';
/**
* Returns the direct child nodes for a given page id in the navigation tree.
* If the page id is omitted, returns the root nodes instead.
*
* @param id - the page id
* @returns the descendants in the navigation tree
*/
getChildNodes(id?: string): Promise<Array<NavigationTreeNode>>;
/**
* Returns the ids of the parents nodes for a given page.
*
* @param page - the reference to the page
* @param includeTerminal - whether to include the final terminal page (default: true)
* @param includeRootNode - whether to include a root node with empty id (default: false)
* @returns the parents nodes ids
* @since 18.0.0RC1
* @beta
**/
getParentNodesId(
page: DocumentReference,
includeTerminal?: boolean,
includeRootNode?: boolean,
): Array<string>;A NavigationTreeNode is a simple data structure that stores all the information required render a node and to navigate the tree:
import type { SpaceReference } from '@xwiki/platform-model-api';
/**
* Description of a navigation tree node.
* @since 18.0.0RC1
* @beta
*/
type NavigationTreeNode = {
/** the id of a node, used by the NavigationTreeSource to access children */
id: string;
label: string;
/**
* The location of the corresponding page on Cristal.
* @since 18.0.0RC1
* @beta
*/
location: SpaceReference;
url: string;
has_children: boolean;
/**
* Whether this node corresponds to a terminal page.
* @since 18.0.0RC1
* @beta
*/
is_terminal: boolean;
};