26 lines
815 B
TypeScript
26 lines
815 B
TypeScript
import Link from "next/link";
|
||||
|
|
|
|||
|
|
/** Previous and next year of a calendar page; the current year is the page without a year. */
|
|||
|
|
export function YearNav({ base, year, current, around }: { base: string; year: number; current: number; around: number }) {
|
|||
|
|
const href = (y: number) => (y === current ? base : `${base}/${y}`);
|
|||
|
|
return (
|
|||
|
|
<nav className="year-nav" aria-label="Év választása">
|
|||
|
|
{year - 1 >= current - around ? (
|
|||
|
|
<Link href={href(year - 1)} className="btn btn-sm">
|
|||
|
|
‹ {year - 1}
|
|||
|
|
</Link>
|
|||
|
|
) : (
|
|||
|
|
<span />
|
|||
|
|
)}
|
|||
|
|
<strong className="num">{year}</strong>
|
|||
|
|
{year + 1 <= current + around ? (
|
|||
|
|
<Link href={href(year + 1)} className="btn btn-sm">
|
|||
|
|
{year + 1} ›
|
|||
|
|
</Link>
|
|||
|
|
) : (
|
|||
|
|
<span />
|
|||
|
|
)}
|
|||
|
|
</nav>
|
|||
|
|
);
|
|||
|
|
}
|