Wiki source code of Front-End hierarchy API

Last modified by Manuel Leduc on 2026/06/22 17:50

Show last authors
1 The Hierarchy API provides components that can be used to access the hierarchy of a given page, which is then used to display, //e.g.,// the breadcrumb on top of all Cristal pages.
2
3 == Existing implementations ==
4
5 * XWiki ##@xwiki/platform-hierarchy-xwiki##
6 * File System ##@xwiki/cristal-hierarchy-filesystem##
7 * GitHub ##@xwiki/cristal-hierarchy-github##
8 * Nextcloud ##@xwiki/cristal-hierarchy-nextcloud##
9
10 == Details ==
11
12 A ##PageHierarchyResolver## is a component that offers a single method:
13
14 {{code language="typescript"}}
15 /**
16 * Returns the page hierarchy for a given page.
17 *
18 * @param pageData the page for which to compute the hierarchy
19 * @returns the page hierarchy
20 **/
21 getPageHierarchy(pageData: PageData): Promise<Array<PageHierarchyItem>>;
22 {{/code}}
23
24 A ##PageHierarchyItem## is a simple data structure that maps a label with an URL to reach the hierarchy component:
25
26 {{code language="typescript"}}
27 /**
28 * Description of a hierarchy item for a given page.
29 **/
30 type PageHierarchyItem = {
31 label: string;
32 pageId: string;
33 url: string;
34 };
35
36 {{/code}}
37
38 Even though there is a default implementation in ##DefaultPageHierarchyResolver##, it is expected that any [[backend>>cristal:Backends.WebHome]] should implement their own ##PageHierarchyProvider## with logic specific to the backend. //*E.g.,*//
39
40 {{code language="typescript"}}
41 /**
42 * Implementation of PageHierarchyResolver for the XWiki backend.
43 **/
44 @injectable()
45 class XWikiPageHierarchyResolver implements PageHierarchyResolver {
46 // XWiki specific implementation.
47 }
48 {{/code}}
49
50 Each backend-specific implementation should be registered with the name of the backend that they support, and will then be available through ##DefaultPageHierarchyResolverProvider.get()## whenever the backend is in use.

Get Connected