'use client'; import { truncateWord } from '@/utils/text'; import React, { PropsWithChildren, ReactNode } from 'react'; import { Breadcrumb, BreadcrumbItem, BreadcrumbLink, BreadcrumbList, BreadcrumbPage, BreadcrumbSeparator, } from '@/components/ui/breadcrumb'; import Link from 'next/link'; type PageHeader = { title?: string | null; titleSlot?: ReactNode; // replaces the title text, e.g. an inline editor description?: string | null; imageUrl?: string | null; coverSlot?: ReactNode; // pinned to the cover's top-end corner, e.g. an edit control breadcrumbs?: Array<{ name: string; href: string }>; }; export default function PageHeader({ ...props }: PropsWithChildren) { return (
{/* Decorative background elements */}
{props.imageUrl && (
)} {props.coverSlot && (
{props.coverSlot}
)}
{props.breadcrumbs && ( {props.breadcrumbs.map((item, index, arr) => ( {index < arr.length - 1 ? ( {truncateWord(item.name, 20)} ) : ( {truncateWord(item.name, 20)} )} {index < arr.length - 1 && } ))} )}

{props.titleSlot ? ( props.titleSlot ) : props.title ? ( truncateWord(props.title, 50) ) : ( Loading... )}

{props.description && (

{props.description}

)}
{props.children && (
{props.children}
)}
); }