refactor: docubook@latest template nextjs-docker
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import {
|
||||
Breadcrumb,
|
||||
BreadcrumbItem,
|
||||
BreadcrumbLink,
|
||||
BreadcrumbList,
|
||||
BreadcrumbPage,
|
||||
BreadcrumbSeparator,
|
||||
@@ -14,20 +13,16 @@ export default function DocsBreadcrumb({ paths }: { paths: string[] }) {
|
||||
<Breadcrumb>
|
||||
<BreadcrumbList>
|
||||
<BreadcrumbItem>
|
||||
<BreadcrumbLink>Docs</BreadcrumbLink>
|
||||
<span>Docs</span>
|
||||
</BreadcrumbItem>
|
||||
{paths.map((path, index) => (
|
||||
<Fragment key={`${path}-${index}`}>
|
||||
<BreadcrumbSeparator />
|
||||
<BreadcrumbItem>
|
||||
{index < paths.length - 1 ? (
|
||||
<BreadcrumbLink className="a">
|
||||
{toTitleCase(path)}
|
||||
</BreadcrumbLink>
|
||||
<span>{toTitleCase(path)}</span>
|
||||
) : (
|
||||
<BreadcrumbPage className="b">
|
||||
{toTitleCase(path)}
|
||||
</BreadcrumbPage>
|
||||
<BreadcrumbPage>{toTitleCase(path)}</BreadcrumbPage>
|
||||
)}
|
||||
</BreadcrumbItem>
|
||||
</Fragment>
|
||||
@@ -38,10 +33,23 @@ export default function DocsBreadcrumb({ paths }: { paths: string[] }) {
|
||||
);
|
||||
}
|
||||
|
||||
const acronyms = new Set([
|
||||
"mdx",
|
||||
"api",
|
||||
"pdf",
|
||||
"cli",
|
||||
"ui",
|
||||
"css",
|
||||
"html",
|
||||
"yaml",
|
||||
"json",
|
||||
"ssr",
|
||||
"ssg",
|
||||
]);
|
||||
|
||||
function toTitleCase(input: string): string {
|
||||
const words = input.split("-");
|
||||
const capitalizedWords = words.map(
|
||||
(word) => word.charAt(0).toUpperCase() + word.slice(1)
|
||||
);
|
||||
return capitalizedWords.join(" ");
|
||||
return input
|
||||
.split("-")
|
||||
.map((w) => (acronyms.has(w) ? w.toUpperCase() : w.charAt(0).toUpperCase() + w.slice(1)))
|
||||
.join(" ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user