Files
caszl-next/app/components/Breadcrumb.tsx

34 lines
899 B
TypeScript
Raw Normal View History

2023-10-30 17:29:35 +08:00
import { Fragment } from "react";
import Link from "next/link";
2023-11-01 17:27:06 +08:00
export interface BreadcrumbItem {
2023-10-30 17:29:35 +08:00
href: string;
title: string;
}
const Breadcrumb = ({ navigations }: { navigations: BreadcrumbItem[] }) => {
return (
2023-11-01 17:27:06 +08:00
<div className={"flex text-xs text-[#13426e] truncate"}>
2023-10-30 17:29:35 +08:00
<span className={"mr-2"}>:</span>
{navigations.map((navigation, index) => {
if (index === navigations.length - 1) {
2023-11-01 17:27:06 +08:00
return (
<span className={"overflow-hidden truncate"} key={navigation.href}>
{navigation.title}
</span>
);
2023-10-30 17:29:35 +08:00
} else {
return (
<Fragment key={navigation.href}>
<Link href={navigation.href}>{navigation.title}</Link>
2023-11-01 17:27:06 +08:00
<span className={"mx-2"}>/</span>
2023-10-30 17:29:35 +08:00
</Fragment>
);
}
})}
</div>
);
};
export default Breadcrumb;