Skip to content

Commit 1954b4a

Browse files
committed
Show related posts
1 parent 7fece6d commit 1954b4a

File tree

4 files changed

+36
-6
lines changed

4 files changed

+36
-6
lines changed

src/components/common/AdFeed.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ import React, { useEffect } from 'react';
22
import styled from 'styled-components';
33
import { mediaQuery } from '../../lib/styles/media';
44

5-
declare global {
6-
interface Window {
7-
adsbygoogle: { [key: string]: unknown }[];
8-
}
9-
}
10-
115
function AdFeed() {
126
useEffect(() => {
137
(window.adsbygoogle = window.adsbygoogle || []).push({});

src/containers/post/PostViewer.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import useNotFound from '../../lib/hooks/useNotFound';
3333
import { Helmet } from 'react-helmet-async';
3434
import { toast } from 'react-toastify';
3535
import MobileLikeButton from '../../components/post/MobileLikeButton';
36+
import RelatedPost from './RelatedPost';
3637

3738
const UserProfileWrapper = styled(VelogResponsive)`
3839
margin-top: 16rem;
@@ -366,6 +367,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
366367
/>
367368
</UserProfileWrapper>
368369
<LinkedPostList linkedPosts={post.linked_posts} />
370+
<RelatedPost />
369371
<PostComments
370372
count={post.comments_count}
371373
comments={post.comments}

src/containers/post/RelatedPost.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import React, { useEffect } from 'react';
2+
import styled from 'styled-components';
3+
4+
function RelatedPost() {
5+
useEffect(() => {
6+
(window.adsbygoogle = window.adsbygoogle || []).push({});
7+
}, []);
8+
9+
return (
10+
<Wrapper>
11+
<ins
12+
className="adsbygoogle"
13+
style={{ display: 'block' }}
14+
data-ad-format="autorelaxed"
15+
data-ad-client="ca-pub-5574866530496701"
16+
data-ad-slot="4990574169"
17+
></ins>
18+
</Wrapper>
19+
);
20+
}
21+
22+
const Wrapper = styled.div`
23+
margin-top: 2rem;
24+
margin-bottom: 2rem;
25+
`;
26+
27+
export default RelatedPost;

src/types/window.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
declare global {
2+
interface Window {
3+
adsbygoogle: { [key: string]: unknown }[];
4+
}
5+
}
6+
7+
export {};

0 commit comments

Comments
 (0)