Skip to content

Commit e53e7c0

Browse files
committed
fix: PR changes
1 parent 7f3bf8b commit e53e7c0

File tree

3 files changed

+13
-30
lines changed

3 files changed

+13
-30
lines changed

apify-docs-theme/src/theme/Heading/index.jsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import { useThemeConfig } from '@docusaurus/theme-common';
22
import { translate } from '@docusaurus/Translate';
33
import useBrokenLinks from '@docusaurus/useBrokenLinks';
44
import clsx from 'clsx';
5-
import React from 'react';
5+
import React, { useEffect } from 'react';
66

77
import { LinkIcon } from '@apify/ui-icons';
8+
import { useCopyToClipboard } from '@apify/ui-library';
89

910
import styles from './styles.module.css';
10-
import { useCopyToClipboard } from './useCopyToClipboard';
1111

1212
export default function Heading({ as: As, id, ...props }) {
1313
const brokenLinks = useBrokenLinks();
@@ -24,14 +24,16 @@ export default function Heading({ as: As, id, ...props }) {
2424
},
2525
});
2626

27-
// H1 headings shouldn't have the copy to clipboard button
28-
if (As === 'h1') {
29-
return <As {...props} />;
30-
}
31-
3227
// Register the anchor ID so Docusaurus can scroll to it
33-
if (id) {
34-
brokenLinks.collectAnchor(id);
28+
useEffect(() => {
29+
if (id) {
30+
brokenLinks.collectAnchor(id);
31+
}
32+
}, [id, brokenLinks]);
33+
34+
// H1 headings and headings without an id shouldn't have the copy to clipboard button
35+
if (As === 'h1' || !id) {
36+
return <As {...props} {...(id && { id })} />;
3537
}
3638

3739
const anchorTitle = translate(

apify-docs-theme/src/theme/Heading/styles.module.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
.headingCopyIcon {
1010
display: none;
11-
transform: translateX(0.25rem);
11+
position: relative;
12+
left: .4rem;
1213
color: var(--ifm-color-emphasis-700);
1314
text-decoration: none;
1415
}

apify-docs-theme/src/theme/Heading/useCopyToClipboard.js

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)