Explorar el Código

Display author info in page side contents

satof3 hace 1 año
padre
commit
7387922dfb

+ 1 - 1
apps/app/src/client/components/AuthorInfo/AuthorInfo.module.scss

@@ -1,7 +1,7 @@
 @use '@growi/core-styles/scss/bootstrap/init' as bs;
 
 $author-font-size: 12px;
-$date-font-size: 11px;
+$date-font-size: 12px;
 
 .grw-author-info :global {
   font-size: $author-font-size;

+ 8 - 8
apps/app/src/client/components/AuthorInfo/AuthorInfo.tsx

@@ -28,20 +28,20 @@ type AuthorInfoProps = {
   date: Date,
   user?: IUserHasId | Ref<IUser>,
   mode: 'create' | 'update',
-  locate: 'subnav' | 'footer',
+  locate: 'pageSide' | 'footer',
 }
 
 export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
   const { t } = useTranslation();
   const {
-    date, user, mode = 'create', locate = 'subnav',
+    date, user, mode = 'create', locate = 'pageSide',
   } = props;
 
   const formatType = 'yyyy/MM/dd HH:mm';
 
-  const infoLabelForSubNav = mode === 'create'
-    ? 'Created by'
-    : 'Updated by';
+  const infoLabelForPageSide = mode === 'create'
+    ? t('author_info.created_at')
+    : t('author_info.last_revision_posted_at');
   const nullinfoLabelForFooter = mode === 'create'
     ? 'Created by'
     : 'Updated by';
@@ -80,9 +80,9 @@ export const AuthorInfo = (props: AuthorInfoProps): JSX.Element => {
       <div className="me-2">
         <UserPicture user={user} size="sm" />
       </div>
-      <div>
-        <div>{infoLabelForSubNav} {userLabel}</div>
-        <div className="text-muted text-date" data-vrt-blackout-datetime>
+      <div className="mb-2">
+        <div className="text-secondary mb-1">{infoLabelForPageSide} by {userLabel}</div>
+        <div className="text-secondary text-date" data-vrt-blackout-datetime>
           {renderParsedDate()}
         </div>
       </div>

+ 2 - 2
apps/app/src/client/components/PageAuthorInfo/PageAuthorInfo.tsx

@@ -32,12 +32,12 @@ export const PageAuthorInfo = memo((): JSX.Element => {
     <ul className={`grw-page-author-info ${styles['grw-page-author-info']} text-nowrap border-start d-none d-lg-block d-edit-none py-2 ps-4 mb-0 ms-3`}>
       <li className="pb-1">
         {currentPage != null && (
-          <AuthorInfo user={currentPage.creator} date={currentPage.createdAt} mode="create" locate="subnav" />
+          <AuthorInfo user={currentPage.creator} date={currentPage.createdAt} mode="create" locate="pageSide" />
         )}
       </li>
       <li className="mt-1 pt-1 border-top">
         {currentPage != null && (
-          <AuthorInfo user={currentPage.lastUpdateUser} date={currentPage.updatedAt} mode="update" locate="subnav" />
+          <AuthorInfo user={currentPage.lastUpdateUser} date={currentPage.updatedAt} mode="update" locate="pageSide" />
         )}
       </li>
     </ul>

+ 10 - 0
apps/app/src/client/components/PageSideContents/PageSideContents.tsx

@@ -28,6 +28,7 @@ const PageTags = dynamic(() => import('../PageTags').then(mod => mod.PageTags),
   loading: PageTagsSkeleton,
 });
 
+const AuthorInfo = dynamic(() => import('~/client/components/AuthorInfo').then(mod => mod.AuthorInfo), { ssr: false });
 
 type TagsProps = {
   pageId: string,
@@ -85,6 +86,10 @@ export const PageSideContents = (props: PageSideContentsProps): JSX.Element => {
 
   const { data: pageInfo } = useSWRxPageInfo(page._id);
 
+  const {
+    creator, lastUpdateUser, createdAt, updatedAt,
+  } = page;
+
   const pagePath = page.path;
   const isTopPagePath = isTopPage(pagePath);
   const isUsersHomepagePath = isUsersHomepage(pagePath);
@@ -92,6 +97,11 @@ export const PageSideContents = (props: PageSideContentsProps): JSX.Element => {
 
   return (
     <>
+      {/* AuthorInfo */}
+      <div className="page-meta border-bottom pb-2 mb-3">
+        <AuthorInfo user={creator} date={createdAt} mode="create" locate="pageSide" />
+        <AuthorInfo user={lastUpdateUser} date={updatedAt} mode="update" locate="pageSide" />
+      </div>
       {/* Tags */}
       { page.revision != null && (
         <div ref={tagsRef}>