add breadcrumbs component
This commit is contained in:
parent
04c436cb34
commit
129e796852
@ -58,3 +58,7 @@ export default async function About() {
|
|||||||
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const getBreadCrumbName = () => {
|
||||||
|
return "Rólunk;"
|
||||||
|
}
|
||||||
|
|||||||
69
yoga-app/src/components/breadcrumbs.component.tsx
Normal file
69
yoga-app/src/components/breadcrumbs.component.tsx
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
'use client'
|
||||||
|
|
||||||
|
import React, { ReactNode } from 'react'
|
||||||
|
|
||||||
|
import {usePathname, useRouter} from 'next/navigation'
|
||||||
|
import Link from 'next/link'
|
||||||
|
|
||||||
|
type Props = {
|
||||||
|
}
|
||||||
|
|
||||||
|
const pathToBreadCrumbs = (path: string) => {
|
||||||
|
const mapping: Record<string, string> = {
|
||||||
|
'/' : 'Kezdőlap',
|
||||||
|
'about' : 'Rólam'
|
||||||
|
}
|
||||||
|
if ( mapping.hasOwnProperty(path)){
|
||||||
|
return mapping[path];
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
const NextBreadcrumb = () => {
|
||||||
|
|
||||||
|
const paths = usePathname()
|
||||||
|
const pathNames = paths.split('/').filter( path => path )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="btn_wrapper">
|
||||||
|
<span className="sub_home_span">{pathToBreadCrumbs( "/" )} </span>
|
||||||
|
{
|
||||||
|
pathNames.map((value,index) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<i className="fa-solid fa-angles-right" aria-hidden="true"></i>
|
||||||
|
<span className="sub_span">{pathToBreadCrumbs( value )}</span>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
// <div>
|
||||||
|
// <ul className={containerClasses}>
|
||||||
|
// <li className={listClasses}><Link href={'/'}>{homeElement}</Link></li>
|
||||||
|
// {pathNames.length > 0 && separator}
|
||||||
|
// {
|
||||||
|
// pathNames.map( (link, index) => {
|
||||||
|
// let href = `/${pathNames.slice(0, index + 1).join('/')}`
|
||||||
|
// let itemClasses = paths === href ? `${listClasses} ${activeClasses}` : listClasses
|
||||||
|
// let itemLink = capitalizeLinks ? link[0].toUpperCase() + link.slice(1, link.length) : link
|
||||||
|
// return (
|
||||||
|
// <React.Fragment key={index}>
|
||||||
|
// <li className={itemClasses} >
|
||||||
|
// <Link href={href}>{itemLink}</Link>
|
||||||
|
// </li>
|
||||||
|
// {pathNames.length !== index + 1 && separator}
|
||||||
|
// </React.Fragment>
|
||||||
|
// )
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// </ul>
|
||||||
|
// </div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NextBreadcrumb
|
||||||
@ -2,6 +2,7 @@ import YogaImageComponent from "@/components/yoga.image.component";
|
|||||||
import Nav from "@/components/nav.component";
|
import Nav from "@/components/nav.component";
|
||||||
import {MAIN_MENU} from "@/util/const";
|
import {MAIN_MENU} from "@/util/const";
|
||||||
import {HeaderB} from "@/types/generated-strapi-interfaces/components/yoga-site/HeaderB";
|
import {HeaderB} from "@/types/generated-strapi-interfaces/components/yoga-site/HeaderB";
|
||||||
|
import NextBreadcrumb from "@/components/breadcrumbs.component";
|
||||||
|
|
||||||
|
|
||||||
export interface Props extends HeaderB{
|
export interface Props extends HeaderB{
|
||||||
@ -18,9 +19,7 @@ const SubHeaderComponent = ({header1,header2,description}: Props) =>{
|
|||||||
<div className="banner-section-content">
|
<div className="banner-section-content">
|
||||||
<h1 data-aos="fade-up">{header1}</h1>
|
<h1 data-aos="fade-up">{header1}</h1>
|
||||||
<p data-aos="fade-right">{description}</p>
|
<p data-aos="fade-right">{description}</p>
|
||||||
<div className="btn_wrapper">
|
<NextBreadcrumb />
|
||||||
<span className="sub_home_span">Home </span><i className="fa-solid fa-angles-right" aria-hidden="true"></i><span className="sub_span"> About</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user