|
@@ -1,13 +1,16 @@
|
|
|
-import React, { useMemo } from 'react';
|
|
|
|
|
|
|
+import React, { useEffect, useMemo } from 'react';
|
|
|
|
|
|
|
|
import { type IPagePopulatedToShowRevision, pagePathUtils } from '@growi/core';
|
|
import { type IPagePopulatedToShowRevision, pagePathUtils } from '@growi/core';
|
|
|
import dynamic from 'next/dynamic';
|
|
import dynamic from 'next/dynamic';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+import { generateSSRViewOptions } from '~/services/renderer/renderer';
|
|
|
import {
|
|
import {
|
|
|
useIsForbidden, useIsIdenticalPath, useIsNotCreatable, useIsNotFound,
|
|
useIsForbidden, useIsIdenticalPath, useIsNotCreatable, useIsNotFound,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
|
|
+import { useViewOptions } from '~/stores/renderer';
|
|
|
import { useIsMobile } from '~/stores/ui';
|
|
import { useIsMobile } from '~/stores/ui';
|
|
|
|
|
+import { registerGrowiFacade } from '~/utils/growi-facade';
|
|
|
|
|
|
|
|
import type { CommentsProps } from '../Comments';
|
|
import type { CommentsProps } from '../Comments';
|
|
|
import { MainPane } from '../Layout/MainPane';
|
|
import { MainPane } from '../Layout/MainPane';
|
|
@@ -32,22 +35,17 @@ const PageSideContents = dynamic<PageSideContentsProps>(() => import('../PageSid
|
|
|
const Comments = dynamic<CommentsProps>(() => import('../Comments').then(mod => mod.Comments), { ssr: false });
|
|
const Comments = dynamic<CommentsProps>(() => import('../Comments').then(mod => mod.Comments), { ssr: false });
|
|
|
const UsersHomePageFooter = dynamic<UsersHomePageFooterProps>(() => import('../UsersHomePageFooter')
|
|
const UsersHomePageFooter = dynamic<UsersHomePageFooterProps>(() => import('../UsersHomePageFooter')
|
|
|
.then(mod => mod.UsersHomePageFooter), { ssr: false });
|
|
.then(mod => mod.UsersHomePageFooter), { ssr: false });
|
|
|
-
|
|
|
|
|
-const IdenticalPathPage = (): JSX.Element => {
|
|
|
|
|
- const IdenticalPathPage = dynamic(() => import('../IdenticalPathPage').then(mod => mod.IdenticalPathPage), { ssr: false });
|
|
|
|
|
- return <IdenticalPathPage />;
|
|
|
|
|
-};
|
|
|
|
|
|
|
+const IdenticalPathPage = dynamic(() => import('../IdenticalPathPage').then(mod => mod.IdenticalPathPage), { ssr: false });
|
|
|
|
|
|
|
|
|
|
|
|
|
type Props = {
|
|
type Props = {
|
|
|
pagePath: string,
|
|
pagePath: string,
|
|
|
page?: IPagePopulatedToShowRevision,
|
|
page?: IPagePopulatedToShowRevision,
|
|
|
- ssrBody?: JSX.Element,
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export const PageView = (props: Props): JSX.Element => {
|
|
export const PageView = (props: Props): JSX.Element => {
|
|
|
const {
|
|
const {
|
|
|
- pagePath, page, ssrBody,
|
|
|
|
|
|
|
+ pagePath, page,
|
|
|
} = props;
|
|
} = props;
|
|
|
|
|
|
|
|
const pageId = page?._id;
|
|
const pageId = page?._id;
|
|
@@ -58,6 +56,19 @@ export const PageView = (props: Props): JSX.Element => {
|
|
|
const { data: isNotFound } = useIsNotFound();
|
|
const { data: isNotFound } = useIsNotFound();
|
|
|
const { data: isMobile } = useIsMobile();
|
|
const { data: isMobile } = useIsMobile();
|
|
|
|
|
|
|
|
|
|
+ const { mutate: mutateRendererOptions } = useViewOptions();
|
|
|
|
|
+
|
|
|
|
|
+ // register to facade
|
|
|
|
|
+ useEffect(() => {
|
|
|
|
|
+ registerGrowiFacade({
|
|
|
|
|
+ markdownRenderer: {
|
|
|
|
|
+ optionsMutators: {
|
|
|
|
|
+ viewOptionsMutator: mutateRendererOptions,
|
|
|
|
|
+ },
|
|
|
|
|
+ },
|
|
|
|
|
+ });
|
|
|
|
|
+ }, [mutateRendererOptions]);
|
|
|
|
|
+
|
|
|
const specialContents = useMemo(() => {
|
|
const specialContents = useMemo(() => {
|
|
|
if (isIdenticalPathPage) {
|
|
if (isIdenticalPathPage) {
|
|
|
return <IdenticalPathPage />;
|
|
return <IdenticalPathPage />;
|