Hierarchy

Last modified by Manuel Leduc on 2025/01/28 09:42

Description

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.

Details

PageHierarchyResolver is a component that offers a single method:

/**
 * Returns the page hierarchy for a given page.
 *
 * @param pageData the page for which to compute the hierarchy
 * @returns the page hierarchy
 **/
getPageHierarchy(pageData: PageData): Promise<Array<PageHierarchyItem>>;

A PageHierarchyItem is a simple data structure that maps a label with an URL to reach the hierarchy component:

/**
 * Description of a hierarchy item for a given page.
 **/
type PageHierarchyItem = {
  label: string;
  pageId: string;
  url: string;
};

Even though there is a default implementation in DefaultPageHierarchyResolver, it is expected that any backend should implement their own PageHierarchyProvider with logic specific to the backend. *E.g.,*

/**
 * Implementation of PageHierarchyResolver for the XWiki backend.
 **/
@injectable()
class XWikiPageHierarchyResolver implements PageHierarchyResolver {
  // XWiki specific implementation.
}

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.

France 2030 Logo

This project is being financed by the French State as part of the France 2030 program

Ce projet est financé par l’État Français dans le cadre de France 2030

  • Powered by XWiki 17.10.9-node2. Hosted and managed by XWiki SAS

Get Connected