Skip to content

Commit 63f586c

Browse files
committed
Fix post recommends
1 parent 3374fe7 commit 63f586c

File tree

2 files changed

+42
-28
lines changed

2 files changed

+42
-28
lines changed

src/containers/post/PostViewer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
373373
comments={post.comments}
374374
postId={post.id}
375375
/>
376-
{/* <RelatedPost type="mobile" /> */}
376+
<RelatedPost type="mobile" />
377377
</PostViewerProvider>
378378
);
379379
};

src/containers/post/RelatedPost.tsx

Lines changed: 41 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,22 @@ type RelatedPostProps = {
88
};
99
function RelatedPost({ type }: RelatedPostProps) {
1010
const [visible, setVisible] = useState(true);
11-
// useEffect(() => {
12-
// setTimeout(() => {
13-
// const width = window.innerWidth;
14-
// if (type === 'desktop' && width < 768) {
15-
// setVisible(false);
16-
// return;
17-
// }
18-
// if (type === 'mobile' && width >= 768) {
19-
// setVisible(false);
20-
// return;
21-
// }
22-
// setTimeout(() => {
23-
// (window.adsbygoogle = window.adsbygoogle || []).push({});
24-
// }, 100);
25-
// }, 250);
26-
// }, [type]);
11+
useEffect(() => {
12+
setTimeout(() => {
13+
const width = window.innerWidth;
14+
if (type === 'desktop' && width < 768) {
15+
setVisible(false);
16+
return;
17+
}
18+
if (type === 'mobile' && width >= 768) {
19+
setVisible(false);
20+
return;
21+
}
22+
setTimeout(() => {
23+
(window.adsbygoogle = window.adsbygoogle || []).push({});
24+
}, 500);
25+
}, 250);
26+
}, [type]);
2727

2828
useEffect(() => {
2929
detectAnyAdblocker().then((detected: boolean) => {
@@ -37,17 +37,31 @@ function RelatedPost({ type }: RelatedPostProps) {
3737

3838
return (
3939
<Wrapper>
40-
<h4>관심 있을 만한 포스트</h4>(
41-
<ins
42-
className="adsbygoogle"
43-
style={{ display: 'block' }}
44-
data-ad-format="autorelaxed"
45-
data-ad-client="ca-pub-5574866530496701"
46-
data-ad-slot="4990574169"
47-
data-matched-content-ui-type="image_stacked"
48-
data-matched-content-rows-num="2"
49-
data-matched-content-columns-num="3"
50-
></ins>
40+
<h4>관심 있을 만한 포스트</h4>
41+
{type === 'desktop' && (
42+
<ins
43+
className="adsbygoogle"
44+
style={{ display: 'block' }}
45+
data-ad-format="autorelaxed"
46+
data-ad-client="ca-pub-5574866530496701"
47+
data-ad-slot="4990574169"
48+
data-matched-content-ui-type="image_stacked"
49+
data-matched-content-rows-num="2"
50+
data-matched-content-columns-num="3"
51+
></ins>
52+
)}
53+
{type === 'mobile' && (
54+
<ins
55+
className="adsbygoogle"
56+
style={{ display: 'block' }}
57+
data-ad-format="autorelaxed"
58+
data-ad-client="ca-pub-5574866530496701"
59+
data-ad-slot="4990574169"
60+
data-matched-content-ui-type="image_stacked"
61+
data-matched-content-rows-num="6"
62+
data-matched-content-columns-num="1"
63+
></ins>
64+
)}
5165
</Wrapper>
5266
);
5367
}

0 commit comments

Comments
 (0)