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

Hide the sidebar if it is a shared page

Shun Miyazawa 3 лет назад
Родитель
Сommit
767a32bede
1 измененных файлов с 22 добавлено и 8 удалено
  1. 22 8
      packages/app/src/components/Layout/BasicLayout.tsx

+ 22 - 8
packages/app/src/components/Layout/BasicLayout.tsx

@@ -1,7 +1,10 @@
 import React, { ReactNode } from 'react';
 import React, { ReactNode } from 'react';
 
 
+import { pagePathUtils } from '@growi/core';
 import dynamic from 'next/dynamic';
 import dynamic from 'next/dynamic';
 
 
+import { useCurrentPathname } from '~/stores/context';
+
 import { GrowiNavbar } from '../Navbar/GrowiNavbar';
 import { GrowiNavbar } from '../Navbar/GrowiNavbar';
 import Sidebar from '../Sidebar';
 import Sidebar from '../Sidebar';
 
 
@@ -34,21 +37,32 @@ export const BasicLayout = ({
   children, title, className, expandContainer,
   children, title, className, expandContainer,
 }: Props): JSX.Element => {
 }: Props): JSX.Element => {
 
 
+  const { data: currentPathname } = useCurrentPathname();
+
+  const isSharedPage = pagePathUtils.isSharedPage(currentPathname ?? '');
+
   const myClassName = `${className ?? ''} ${expandContainer ? 'growi-layout-fluid' : ''}`;
   const myClassName = `${className ?? ''} ${expandContainer ? 'growi-layout-fluid' : ''}`;
 
 
   return (
   return (
     <RawLayout title={title} className={myClassName}>
     <RawLayout title={title} className={myClassName}>
       <GrowiNavbar />
       <GrowiNavbar />
 
 
-      <div className="page-wrapper d-flex d-print-block">
-        <div className="grw-sidebar-wrapper">
-          <Sidebar />
-        </div>
+      {isSharedPage
+        ? (
+          <>{children}</>
+        )
+        : (
+          <div className="page-wrapper d-flex d-print-block">
+            <div className="grw-sidebar-wrapper">
+              <Sidebar />
+            </div>
 
 
-        <div className="flex-fill mw-0">
-          {children}
-        </div>
-      </div>
+            <div className="flex-fill mw-0">
+              {children}
+            </div>
+          </div>
+        )
+      }
 
 
       <GrowiNavbarBottom />
       <GrowiNavbarBottom />