import React, { FC } from 'react';
import AppContainer from '~/client/services/AppContainer';
import loggerFactory from '~/utils/logger';
import { useSWRxPageByPath } from '~/stores/page';
import { withUnstatedContainers } from '../UnstatedUtils';
import RevisionRenderer from '../Page/RevisionRenderer';
import { IRevision } from '~/interfaces/revision';
const logger = loggerFactory('growi:cli:CustomSidebar');
const SidebarNotFound = () => {
return (
);
};
type Props = {
appContainer: AppContainer,
};
const CustomSidebar: FC = (props: Props) => {
const { appContainer } = props;
const renderer = appContainer.getRenderer('sidebar');
const { data: page, error, mutate } = useSWRxPageByPath('/Sidebar');
const isLoading = page === undefined && error == null;
const markdown = (page?.revision as IRevision | undefined)?.body;
return (
<>
Custom Sidebar
{
isLoading && (
)
}
{
(!isLoading && markdown != null) && (
)
}
{
(!isLoading && markdown === undefined) && (
)
}
>
);
};
/**
* Wrapper component for using unstated
*/
const CustomSidebarWrapper = withUnstatedContainers(CustomSidebar, [AppContainer]);
export default CustomSidebarWrapper;