Просмотр исходного кода

Merge pull request #6950 from weseek/fix/109119-make-body-template-work

fix: Make body template work
Yuki Takei 3 лет назад
Родитель
Сommit
bd935e9700
1 измененных файлов с 6 добавлено и 4 удалено
  1. 6 4
      packages/app/src/pages/[[...path]].page.tsx

+ 6 - 4
packages/app/src/pages/[[...path]].page.tsx

@@ -145,6 +145,7 @@ type Props = CommonProps & {
   // isAbleToDeleteCompletely: boolean,
 
   templateTagData?: string[],
+  templateBodyData?: string,
 
   isSearchServiceConfigured: boolean,
   isSearchServiceReachable: boolean,
@@ -250,7 +251,7 @@ const GrowiPage: NextPage<Props> = (props: Props) => {
   useCurrentRevisionId(props.currentRevisionId);
 
   const { data: currentPage } = useSWRxCurrentPage(undefined, pageWithMeta?.data ?? null); // store initial data
-  useEditingMarkdown(pageWithMeta?.data.revision?.body ?? '');
+  useEditingMarkdown(pageWithMeta?.data.revision?.body ?? props.templateBodyData ?? '');
 
   const { data: grantData } = useSWRxIsGrantNormalized(pageId);
   const { mutate: mutateSelectedGrant } = useSelectedGrant();
@@ -426,9 +427,10 @@ async function injectPageData(context: GetServerSidePropsContext, props: Props):
   }
 
   if (page == null && user != null) {
-    const template = await Page.findTemplate(props.currentPathname);
-    if (template != null) {
-      props.templateTagData = template.templateTags as string[];
+    const templateData = await Page.findTemplate(props.currentPathname);
+    if (templateData != null) {
+      props.templateTagData = templateData.templateTags as string[];
+      props.templateBodyData = templateData.templateBody as string;
     }
   }