import React, { type JSX } from 'react'; import Link from 'next/link'; import type { IPageHasId } from '@growi/core'; import { useTranslation } from 'next-i18next'; import { useCurrentPagePath } from '~/states/page'; import { useSWRINFxPageTimeline } from '~/stores/page-timeline'; import { useTimelineOptions } from '~/stores/renderer'; import InfiniteScroll from './InfiniteScroll'; import { RevisionLoader } from './Page/RevisionLoader'; import styles from './PageTimeline.module.scss'; type TimelineCardProps = { page: IPageHasId; }; const TimelineCard = ({ page }: TimelineCardProps): JSX.Element => { const { data: rendererOptions } = useTimelineOptions(page.path); return (
{page.path}
{rendererOptions != null && page.revision != null && ( )}
); }; export const PageTimeline = (): JSX.Element => { const PER_PAGE = 3; const { t } = useTranslation(); const currentPagePath = useCurrentPagePath(); const swrInfinitexPageTimeline = useSWRINFxPageTimeline( currentPagePath ?? undefined, PER_PAGE, ); const { data } = swrInfinitexPageTimeline; const isEmpty = data?.[0]?.pages.length === 0; const isReachingEnd = isEmpty || (data != null && data[data.length - 1]?.pages.length < PER_PAGE); if (data == null || isEmpty) { return (

{t('custom_navigation.no_pages_under_this_page')}

); } return (
{data != null && data .flatMap((apiResult) => apiResult.pages) .map((page) => )}
); };