import { Disclosure } from '@headlessui/react'; import { ChevronRightIcon } from '@heroicons/react/solid'; import * as React from 'react'; import { useRecoilValue } from 'recoil'; import { groupBy } from '../../../helpers/GroupBy'; import { FrontMatterIcon } from '../../../panelWebView/components/Icons/FrontMatterIcon'; import { GroupOption } from '../../constants/GroupOption'; import { Page } from '../../models/Page'; import { Settings } from '../../models/Settings'; import { GroupingSelector } from '../../state'; import { Item } from './Item'; import { List } from './List'; export interface IOverviewProps { pages: Page[]; settings: Settings | null; } export const Overview: React.FunctionComponent = ({pages, settings}: React.PropsWithChildren) => { const grouping = useRecoilValue(GroupingSelector); if (!pages || !pages.length) { return (
{ settings && settings?.folders?.length > 0 ? (

No Markdown to show

) : ( <>

Make sure you registered a content folder in your project to let Front Matter find the contents.

) }
); } if (grouping !== GroupOption.none) { const groupedPages = groupBy(pages, grouping === GroupOption.Year ? 'fmYear' : 'fmDraft'); let groupKeys = Object.keys(groupedPages); if (grouping === GroupOption.Year) { groupKeys = groupKeys.sort((a, b) => { return parseInt(b) - parseInt(a) }); } return ( <> { groupKeys.map((groupId, idx) => ( {({ open }) => ( <>

{GroupOption[grouping]}: {groupId} ({groupedPages[groupId].length})

{groupedPages[groupId].map((page: Page) => ( ))} )}
)) } ); } return ( {pages.map((page, idx) => ( ))} ); };