|
| 1 | +/** |
| 2 | + * EditMetaRow is a component that renders the edit and last updated |
| 3 | + * metadata for a page. This component is displayed at the bottom of |
| 4 | + * each page. |
| 5 | + * |
| 6 | + * Original source: |
| 7 | + * @link https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/EditMetaRow/index.tsx |
| 8 | + * |
| 9 | + * Reason for overriding: |
| 10 | + * - Add a copy page button next to the edit this page link |
| 11 | + * - Wrap the whole last updated section in a conditional, not just |
| 12 | + * its contents. Otherwise the empty column still reserves half the |
| 13 | + * row. |
| 14 | + */ |
| 15 | + |
| 16 | +import React, { type ReactNode } from 'react'; |
| 17 | +import clsx from 'clsx'; |
| 18 | +// CUSTOM CODE |
| 19 | +import CopyPageButton from 'docusaurus-plugin-copy-page-button/react'; |
| 20 | +// CUSTOM CODE END |
| 21 | +import EditThisPage from '@theme/EditThisPage'; |
| 22 | +import type { Props } from '@theme/EditMetaRow'; |
| 23 | + |
| 24 | +import LastUpdated from '@theme/LastUpdated'; |
| 25 | + |
| 26 | +import globalStyles from '@docusaurus/theme-classic/lib/theme/EditMetaRow/styles.module.css'; |
| 27 | +import styles from './styles.module.css'; |
| 28 | + |
| 29 | +export default function EditMetaRow({ className, editUrl, lastUpdatedAt, lastUpdatedBy }: Props): ReactNode { |
| 30 | + return ( |
| 31 | + <div className={clsx('row', className)}> |
| 32 | + {/* CUSTOM CODE — "Edit this page | Copy page" as peer links on one row */} |
| 33 | + <div className={clsx('col', styles.editMetaActions)}> |
| 34 | + {editUrl && <EditThisPage editUrl={editUrl} />} |
| 35 | + <CopyPageButton |
| 36 | + customStyles={{ |
| 37 | + container: { className: styles.copyPageContainer }, |
| 38 | + button: { className: styles.copyPageButton }, |
| 39 | + }} |
| 40 | + /> |
| 41 | + </div> |
| 42 | + {/* CUSTOM CODE END */} |
| 43 | + {/* CUSTOM CODE — wrap the whole column in the conditional, not just its contents */} |
| 44 | + {(lastUpdatedAt || lastUpdatedBy) && ( |
| 45 | + <div className={clsx('col', globalStyles.lastUpdated)}> |
| 46 | + <LastUpdated lastUpdatedAt={lastUpdatedAt} lastUpdatedBy={lastUpdatedBy} /> |
| 47 | + </div> |
| 48 | + )} |
| 49 | + {/* CUSTOM CODE END */} |
| 50 | + </div> |
| 51 | + ); |
| 52 | +} |
0 commit comments