import React from 'react'; import { IPageHasId, pagePathUtils } from '@growi/core'; import { useTranslation } from 'next-i18next'; import { Link } from 'react-scroll'; import { DEFAULT_AUTO_SCROLL_OPTS } from '~/client/util/smooth-scroll'; import { useCurrentPathname } from '~/stores/context'; import { useDescendantsPageListModal } from '~/stores/modal'; import CountBadge from './Common/CountBadge'; import { ContentLinkButtons } from './ContentLinkButtons'; import PageListIcon from './Icons/PageListIcon'; import TableOfContents from './TableOfContents'; import styles from './PageSideContents.module.scss'; const { isTopPage, isUsersHomePage } = pagePathUtils; export type PageSideContentsProps = { page?: IPageHasId, isSharedUser?: boolean, } export const PageSideContents = (props: PageSideContentsProps): JSX.Element => { const { t } = useTranslation(); const { data: currentPathname } = useCurrentPathname(); const { open: openDescendantPageListModal } = useDescendantsPageListModal(); const { page, isSharedUser } = props; const pagePath = page?.path ?? currentPathname; const isTopPagePath = isTopPage(pagePath ?? ''); const isUsersHomePagePath = isUsersHomePage(pagePath ?? ''); return ( <> {/* Page list */}
{ pagePath != null && !isSharedUser && ( ) }
{/* Comments */} { page != null && !isTopPagePath && (
) }
{ isUsersHomePagePath && }
); };