UNPKG

@scayle/storefront-core

Version:

Collection of essential utilities to work with the Storefront API

46 lines (45 loc) 1.85 kB
import type { Category, ProductCategory } from '../types/sapi/category'; import type { BreadcrumbItem } from '../types/breadcrumb'; /** * Generates breadcrumb items from an array of product categories. * * @param categories An array of product categories. * * @returns An array of breadcrumb items. */ export declare const getBreadcrumbsFromProductCategories: (categories: ProductCategory[] | Category[]) => BreadcrumbItem[]; /** * Generates breadcrumb items from a category object, optionally highlighting an active node. * * @param category The root category object. * @param activeNode The currently active category (optional). * * @returns An array of breadcrumb items. */ export declare const getBreadcrumbsFromCategory: (category: Category, activeNode?: Category) => BreadcrumbItem[]; /** * Generates breadcrumb items from a path string. * * @param path The path string. * @param shopLocale The shop locale (optional). * * @returns An array of breadcrumb items. */ export declare const getBreadcrumbsFromPath: (path?: string, shopLocale?: string) => BreadcrumbItem[]; /** * Generates breadcrumb items based on either product categories or a single category object. * * @param categories An array of product categories or a single category object. * @param activeNode The currently active category (optional, used only when categories is a single Category object). * * @returns An array of breadcrumb items. */ export declare const getBreadcrumbs: (categories: ProductCategory[] | Category, activeNode?: Category) => BreadcrumbItem[]; /** * Extracts the back URL from an array of breadcrumb items. * * @param breadcrumbs An array of breadcrumb items. * * @returns The back URL or '/' if breadcrumbs is undefined or empty. */ export declare const getBackURLFromBreadcrumbs: (breadcrumbs?: BreadcrumbItem[]) => string;