32 lines
1009 B
JavaScript
32 lines
1009 B
JavaScript
import React from 'react';
|
|
import { useLocation } from 'react-router-dom';
|
|
import { navLinks } from '../routes.jsx';
|
|
import './PageHeader.css';
|
|
|
|
const PageHeader = () => {
|
|
const { pathname } = useLocation();
|
|
|
|
// Home 페이지에서는 Hero 섹션이 있으므로 숨김
|
|
if (pathname === '/') return null;
|
|
|
|
// stock/trade 같은 하위 경로도 stock로 매칭
|
|
const current = navLinks.find((link) => {
|
|
if (link.path === '/') return false;
|
|
return pathname === link.path || pathname.startsWith(link.path + '/');
|
|
});
|
|
|
|
if (!current) return null;
|
|
|
|
return (
|
|
<header className="page-header" style={{ '--page-accent': current.accent }}>
|
|
<div className="page-header__inner">
|
|
<p className="page-header__subtitle">{current.subtitle}</p>
|
|
<h1 className="page-header__title">{current.label}</h1>
|
|
</div>
|
|
<div className="page-header__line" />
|
|
</header>
|
|
);
|
|
};
|
|
|
|
export default PageHeader;
|