🪛 04 breadcrumbs
This commit is contained in:
15
app/@breadcrumbs/about/page.tsx
Normal file
15
app/@breadcrumbs/about/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
|
||||
export default function AboutBreadcrumb() {
|
||||
return (
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: 'Despre',
|
||||
href: '/about',
|
||||
current: true,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
53
app/@breadcrumbs/blog/[...slug]/page.tsx
Normal file
53
app/@breadcrumbs/blog/[...slug]/page.tsx
Normal file
@@ -0,0 +1,53 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
import { getPostBySlug } from '@/lib/markdown';
|
||||
|
||||
interface BreadcrumbItem {
|
||||
label: string;
|
||||
href: string;
|
||||
current?: boolean;
|
||||
}
|
||||
|
||||
function formatDirectoryName(name: string): string {
|
||||
const directoryNames: { [key: string]: string } = {
|
||||
tech: 'Tehnologie',
|
||||
design: 'Design',
|
||||
tutorial: 'Tutoriale',
|
||||
};
|
||||
|
||||
return directoryNames[name] || name.charAt(0).toUpperCase() + name.slice(1);
|
||||
}
|
||||
|
||||
export default async function BlogPostBreadcrumb({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string[] }>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
const slugPath = slug.join('/');
|
||||
const post = getPostBySlug(slugPath);
|
||||
|
||||
const items: BreadcrumbItem[] = [
|
||||
{
|
||||
label: 'Blog',
|
||||
href: '/blog',
|
||||
},
|
||||
];
|
||||
|
||||
if (slug.length > 1) {
|
||||
for (let i = 0; i < slug.length - 1; i++) {
|
||||
const segmentPath = slug.slice(0, i + 1).join('/');
|
||||
items.push({
|
||||
label: formatDirectoryName(slug[i]),
|
||||
href: `/blog/${segmentPath}`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
items.push({
|
||||
label: post ? post.frontmatter.title : slug[slug.length - 1],
|
||||
href: `/blog/${slugPath}`,
|
||||
current: true,
|
||||
});
|
||||
|
||||
return <Breadcrumbs items={items} />;
|
||||
}
|
||||
15
app/@breadcrumbs/blog/page.tsx
Normal file
15
app/@breadcrumbs/blog/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
|
||||
export default function BlogBreadcrumb() {
|
||||
return (
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: 'Blog',
|
||||
href: '/blog',
|
||||
current: true,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
7
app/@breadcrumbs/default.tsx
Normal file
7
app/@breadcrumbs/default.tsx
Normal file
@@ -0,0 +1,7 @@
|
||||
'use client';
|
||||
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
|
||||
export default function DefaultBreadcrumb() {
|
||||
return <Breadcrumbs />;
|
||||
}
|
||||
29
app/@breadcrumbs/tags/[tag]/page.tsx
Normal file
29
app/@breadcrumbs/tags/[tag]/page.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
|
||||
export default async function TagBreadcrumb({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ tag: string }>;
|
||||
}) {
|
||||
const { tag } = await params;
|
||||
const tagName = tag
|
||||
.split('-')
|
||||
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
||||
.join(' ');
|
||||
|
||||
return (
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: 'Tag-uri',
|
||||
href: '/tags',
|
||||
},
|
||||
{
|
||||
label: tagName,
|
||||
href: `/tags/${tag}`,
|
||||
current: true,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
15
app/@breadcrumbs/tags/page.tsx
Normal file
15
app/@breadcrumbs/tags/page.tsx
Normal file
@@ -0,0 +1,15 @@
|
||||
import { Breadcrumbs } from '@/components/layout/Breadcrumbs';
|
||||
|
||||
export default function TagsBreadcrumb() {
|
||||
return (
|
||||
<Breadcrumbs
|
||||
items={[
|
||||
{
|
||||
label: 'Tag-uri',
|
||||
href: '/tags',
|
||||
current: true,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -1 +1,11 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@layer utilities {
|
||||
.scrollbar-hide {
|
||||
-ms-overflow-style: none;
|
||||
scrollbar-width: none;
|
||||
}
|
||||
.scrollbar-hide::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,8 +27,10 @@ export const metadata: Metadata = {
|
||||
|
||||
export default function RootLayout({
|
||||
children,
|
||||
breadcrumbs,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
breadcrumbs: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<html lang="ro">
|
||||
@@ -48,6 +50,7 @@ export default function RootLayout({
|
||||
</div>
|
||||
</nav>
|
||||
</header>
|
||||
{breadcrumbs}
|
||||
<main className="container mx-auto px-4 py-8">
|
||||
{children}
|
||||
</main>
|
||||
|
||||
Reference in New Issue
Block a user