import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import { Fragment } from "react";
export default function DocsBreadcrumb({ paths }: { paths: string[] }) {
return (
Docs
{paths.map((path, index) => (
{index < paths.length - 1 ? (
{toTitleCase(path)}
) : (
{toTitleCase(path)}
)}
))}
);
}
const acronyms = new Set([
"mdx",
"api",
"pdf",
"cli",
"ui",
"css",
"html",
"yaml",
"json",
"ssr",
"ssg",
]);
function toTitleCase(input: string): string {
return input
.split("-")
.map((w) => (acronyms.has(w) ? w.toUpperCase() : w.charAt(0).toUpperCase() + w.slice(1)))
.join(" ");
}