Functions
The functions of @poltura/theme-sdk/navigation.
On this page
import { … } from '@poltura/theme-sdk/navigation';findCategory
Finds a category of the navigation tree by its id or by the path of its handles.
findCategory(nav: NavData, by: {
readonly id: string;
} | {
readonly path: readonly string[];
}): NavCategory | nullParameters
nav: NavData: The tree, fromuseNavData.by: { readonly id: string; } | { readonly path: readonly string[]; }: The category's id, or the handles from the top-level category down.
Returns: The category with its subcategories, or null when the tree has none such.
Example
import { findCategory, useNavData } from '@poltura/theme-sdk/navigation';
export function SubcategoryLinks({ id }: { id: string }) {
const category = findCategory(useNavData(), { id });
return (
<ul>
{category?.children.map((child) => (
<li key={child.id}>
<a href={child.href}>{child.name}</a>
</li>
))}
</ul>
);
}