import React from 'react' import './styles.scss' import { Scrollchor } from 'react-scrollchor' interface ChapterNavigationI { /** Array of content objects. Each object needs a name and a id property. Name is shown and the id is the id of the anchor link to scroll to. */ content?: { name: string; id: string; [key: string]: any }[] /** title to show above the navigation */ title?: string /** hides first entry in content-array */ hideFirstEntry?: boolean /** hides arrows */ hideArrows?: boolean /** custom css-classname for navigation container */ className?: string /** does a jump instead of scrolling */ jump?: boolean } /** * Displays a navigation for different parts of on article. To use it mark target elements with the same id-property * */ export const ChapterNavigation = ({ content, title, hideFirstEntry, hideArrows, className = 'cbChapterNavigation', jump, }: ChapterNavigationI) => { if (!content) { return (
{title || 'Kapitel-Navigation'}
Kapitel 1
{!hideArrows && (
)}
Kapitel 2
{!hideArrows && (
)}
Kapitel 3
{!hideArrows && (
)}
) } return (
{title &&
{title}
} {content.map((chapter, i) => { if (i === 0 && hideFirstEntry) return return ( {}}:undefined} className='entry' >
{chapter.name}
{!hideArrows && (
)}
) })}
) }