jam411 3 лет назад
Родитель
Сommit
ce1c9f25dc

+ 20 - 22
packages/app/src/components/Navbar/AuthorInfo.jsx → packages/app/src/components/Navbar/AuthorInfo.tsx

@@ -1,18 +1,27 @@
 import React from 'react';
 import React from 'react';
-import PropTypes from 'prop-types';
 import { format } from 'date-fns';
 import { format } from 'date-fns';
 import { UserPicture } from '@growi/ui';
 import { UserPicture } from '@growi/ui';
 import { pagePathUtils } from '@growi/core';
 import { pagePathUtils } from '@growi/core';
+import type { IUser } from '@growi/core';
+import Link from 'next/link';
 
 
-const { userPageRoot } = pagePathUtils;
+type AuthorInfoProps = {
+  date: Date,
+  user: IUser,
+  mode: 'create' | 'update',
+  locate: 'subnav' | 'footer',
+}
 
 
-
-const formatType = 'yyyy/MM/dd HH:mm';
-const AuthorInfo = (props) => {
+export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
   const {
   const {
-    mode, user, date, locate,
+    date, user, mode = 'create', locate = 'subnav',
   } = props;
   } = props;
 
 
+  console.log(mode, locate)
+
+  const { userPageRoot } = pagePathUtils;
+  const formatType = 'yyyy/MM/dd HH:mm';
+
   const infoLabelForSubNav = mode === 'create'
   const infoLabelForSubNav = mode === 'create'
     ? 'Created by'
     ? 'Created by'
     : 'Updated by';
     : 'Updated by';
@@ -23,7 +32,11 @@ const AuthorInfo = (props) => {
     ? 'Created at'
     ? 'Created at'
     : 'Last revision posted at';
     : 'Last revision posted at';
   const userLabel = user != null
   const userLabel = user != null
-    ? <a href={userPageRoot(user)}>{user.name}</a>
+    ? (
+      <Link href={userPageRoot(user)}>
+        <a>{user.name}</a>
+      </Link>
+    )
     : <i>Unknown</i>;
     : <i>Unknown</i>;
 
 
   if (locate === 'footer') {
   if (locate === 'footer') {
@@ -61,18 +74,3 @@ const AuthorInfo = (props) => {
     </div>
     </div>
   );
   );
 };
 };
-
-AuthorInfo.propTypes = {
-  date: PropTypes.instanceOf(Date),
-  user: PropTypes.object,
-  mode: PropTypes.oneOf(['create', 'update']),
-  locate: PropTypes.oneOf(['subnav', 'footer']),
-};
-
-AuthorInfo.defaultProps = {
-  mode: 'create',
-  locate: 'subnav',
-};
-
-
-export default AuthorInfo;

+ 1 - 1
packages/app/src/components/Navbar/GrowiContextualSubNavigation.tsx

@@ -56,7 +56,7 @@ const SubNavButtons = dynamic<SubNavButtonsProps>(
   () => import('./SubNavButtons').then(mod => mod.SubNavButtons),
   () => import('./SubNavButtons').then(mod => mod.SubNavButtons),
   { ssr: false, loading: () => <></> },
   { ssr: false, loading: () => <></> },
 );
 );
-const AuthorInfo = dynamic(() => import('./AuthorInfo'), {
+const AuthorInfo = dynamic(() => import('./AuthorInfo').then(mod => mod.AuthorInfo), {
   ssr: false,
   ssr: false,
   loading: AuthorInfoSkelton,
   loading: AuthorInfoSkelton,
 });
 });

+ 1 - 1
packages/app/src/components/PageContentFooter.tsx

@@ -9,7 +9,7 @@ import { Skelton } from './Skelton';
 
 
 import styles from './PageContentFooter.module.scss';
 import styles from './PageContentFooter.module.scss';
 
 
-const AuthorInfo = dynamic(() => import('./Navbar/AuthorInfo'), {
+const AuthorInfo = dynamic(() => import('./Navbar/AuthorInfo').then(mod => mod.AuthorInfo), {
   ssr: false,
   ssr: false,
   loading: () => <Skelton additionalClass={`${styles['page-content-footer-skelton']} mb-3`} />,
   loading: () => <Skelton additionalClass={`${styles['page-content-footer-skelton']} mb-3`} />,
 });
 });