Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,12 @@ module.exports = {
versions: VERSIONS_JSON,
},
],
[
'docusaurus-plugin-copy-page-button',
{
injectButton: false,
},
],
],
customFields: {},
themes: [],
Expand Down
14 changes: 14 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"clsx": "^1.1.1",
"concurrently": "^6.2.0",
"crowdin": "^3.5.0",
"docusaurus-plugin-copy-page-button": "^0.8.2",
"docusaurus-plugin-module-alias": "^0.0.2",
"docusaurus-plugin-sass": "^0.2.6",
"fs-extra": "^9.1.0",
Expand Down
5 changes: 2 additions & 3 deletions src/styles/components/_edit-this-page.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
:root {
--edit-this-page-c: var(--ifm-link-color);
--edit-this-page-opacity: 0.7;
}

.theme-edit-this-page {
Expand All @@ -9,8 +10,6 @@

grid-template-columns: 0.875rem 1fr;

margin-block-start: 1.25rem;

color: var(--edit-this-page-c);

transition: opacity 0.2s ease-out;
Expand All @@ -19,6 +18,6 @@
&:active,
&:focus {
color: var(--edit-this-page-c);
opacity: 0.7;
opacity: var(--edit-this-page-opacity);
}
}
1 change: 1 addition & 0 deletions src/styles/components/_toc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ html[data-theme='dark'] {
.theme-edit-this-page {
--edit-this-page-c: var(--ifm-heading-color);

margin-block-start: 1.25rem;
font-weight: 600;
font-size: 0.875rem;
}
Expand Down
52 changes: 52 additions & 0 deletions src/theme/EditMetaRow/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* EditMetaRow is a component that renders the edit and last updated
* metadata for a page. This component is displayed at the bottom of
* each page.
*
* Original source:
* @link https://github.com/facebook/docusaurus/blob/main/packages/docusaurus-theme-classic/src/theme/EditMetaRow/index.tsx
*
* Reason for overriding:
* - Add a copy page button next to the edit this page link
* - Wrap the whole last updated section in a conditional, not just
* its contents. Otherwise the empty column still reserves half the
* row.
*/

import React, { type ReactNode } from 'react';
import clsx from 'clsx';
// CUSTOM CODE
import CopyPageButton from 'docusaurus-plugin-copy-page-button/react';
// CUSTOM CODE END
import EditThisPage from '@theme/EditThisPage';
import type { Props } from '@theme/EditMetaRow';

import LastUpdated from '@theme/LastUpdated';

import globalStyles from '@docusaurus/theme-classic/lib/theme/EditMetaRow/styles.module.css';
import styles from './styles.module.css';

export default function EditMetaRow({ className, editUrl, lastUpdatedAt, lastUpdatedBy }: Props): ReactNode {
return (
<div className={clsx('row', className)}>
{/* CUSTOM CODE — "Edit this page | Copy page" as peer links on one row */}
<div className={clsx('col', styles.editMetaActions)}>
{editUrl && <EditThisPage editUrl={editUrl} />}
<CopyPageButton
customStyles={{
container: { className: styles.copyPageContainer },
button: { className: styles.copyPageButton },
}}
/>
</div>
{/* CUSTOM CODE END */}
{/* CUSTOM CODE — wrap the whole column in the conditional, not just its contents */}
{(lastUpdatedAt || lastUpdatedBy) && (
<div className={clsx('col', globalStyles.lastUpdated)}>
<LastUpdated lastUpdatedAt={lastUpdatedAt} lastUpdatedBy={lastUpdatedBy} />
</div>
)}
{/* CUSTOM CODE END */}
</div>
);
}
42 changes: 42 additions & 0 deletions src/theme/EditMetaRow/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
.editMetaActions {
display: inline-flex;
align-items: center;
}

.editMetaActions > :not(:first-child) {
margin-inline-start: 0.85rem;
padding-inline-start: 0.85rem;
border-inline-start: 1px solid var(--ifm-color-emphasis-300);
}

.copyPageContainer {
display: inline-flex;
align-items: center;
}

/* Make the "Copy page" button look like the "Edit this page" link */
.copyPageButton {
display: inline-flex;
align-items: center;
gap: 0.3rem;
border: none;
background: transparent !important;
padding: 0;
margin: 0;
color: var(--edit-this-page-c) !important;
font: inherit;
}

.copyPageButton:hover,
.copyPageButton:active,
.copyPageButton:focus {
opacity: var(--edit-this-page-opacity);
}

/* The plugin hides the button's text label for small screens; keep it visible at all sizes. */
@media (max-width: 767px) {
.copyPageButton [class*='copyPageText'] {
display: inline;
}
}
/* CUSTOM CODE END */
Loading