Skip to content

Commit 9804a4f

Browse files
committed
Move copy-page button from left sidebar to top of TOC (right sidebar)
1 parent 7bed115 commit 9804a4f

3 files changed

Lines changed: 28 additions & 12 deletions

File tree

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Wraps the original DocItem/TOC/Desktop to render the page-level
3+
* copy/AI dropdown above the "Contents" heading in the right sidebar.
4+
*/
5+
6+
import React from 'react';
7+
import CopyPageButton from 'docusaurus-plugin-copy-page-button/react';
8+
import TOCDesktop from '@theme-original/DocItem/TOC/Desktop';
9+
10+
import styles from './styles.module.css';
11+
12+
export default function TOCDesktopWrapper(): JSX.Element {
13+
return (
14+
<>
15+
<div className={styles.copyPageAction}>
16+
<CopyPageButton
17+
customStyles={{
18+
container: { className: styles.copyPageContainer },
19+
button: { className: styles.copyPageButton },
20+
dropdown: { className: styles.copyPageDropdown },
21+
}}
22+
/>
23+
</div>
24+
<TOCDesktop />
25+
</>
26+
);
27+
}

src/theme/DocSidebar/styles.module.css renamed to src/theme/DocItem/TOC/Desktop/styles.module.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
.copyPageAction {
2-
padding: 0 var(--sidebar-spacing-horizontal) 1rem;
2+
margin-bottom: 1rem;
33
}
44

55
.copyPageContainer {

src/theme/DocSidebar/index.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88

99
import React, { useEffect } from 'react';
1010
import { useLocation } from '@docusaurus/router';
11-
import CopyPageButton from 'docusaurus-plugin-copy-page-button/react';
1211
import DocSidebar from '@theme-original/DocSidebar';
1312
import type { Props } from '@theme/DocSidebar';
1413

1514
import Logo from '@theme-original/Logo';
16-
import styles from './styles.module.css';
1715

1816
export default function DocSidebarWrapper(props: Props): JSX.Element {
1917
const location = useLocation();
@@ -30,15 +28,6 @@ export default function DocSidebarWrapper(props: Props): JSX.Element {
3028
return (
3129
<>
3230
<Logo />
33-
<div className={styles.copyPageAction}>
34-
<CopyPageButton
35-
customStyles={{
36-
container: { className: styles.copyPageContainer },
37-
button: { className: styles.copyPageButton },
38-
dropdown: { className: styles.copyPageDropdown },
39-
}}
40-
/>
41-
</div>
4231
<DocSidebar {...props} />
4332
</>
4433
);

0 commit comments

Comments
 (0)