Skip to content

Commit 11cbfde

Browse files
committed
Merge branch 'master' into feature/follow
# Conflicts: # src/containers/post/PostViewer.tsx
2 parents 5d3030c + d8ccfa7 commit 11cbfde

File tree

4 files changed

+49
-54
lines changed

4 files changed

+49
-54
lines changed

src/components/common/AdFeed.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ function AdFeed({ forPost, index }: { forPost?: boolean; index: number }) {
6464
className="adsbygoogle"
6565
style={{ display: 'block' }}
6666
data-ad-format="fluid"
67-
data-ad-layout-key="-6u+e5+1a-3q+77"
68-
data-ad-client="ca-pub-5574866530496701"
69-
data-ad-slot="2841722540"
67+
data-ad-layout-key="-6c+ce+2v-x+66"
68+
data-ad-client="ca-pub-9161852896103498"
69+
data-ad-slot="9446928451"
7070
></ins>
7171
</Block>
7272
);
@@ -87,18 +87,18 @@ function AdFeed({ forPost, index }: { forPost?: boolean; index: number }) {
8787
className="adsbygoogle"
8888
style={{ display: 'block' }}
8989
data-ad-format="fluid"
90-
data-ad-layout-key="-6u+e5+1a-3q+77"
91-
data-ad-client="ca-pub-5574866530496701"
92-
data-ad-slot="8480422066"
90+
data-ad-layout-key="-6c+ce+2v-x+66"
91+
data-ad-client="ca-pub-9161852896103498"
92+
data-ad-slot="2793890198"
9393
></ins>
9494
) : (
9595
<ins
9696
className="adsbygoogle"
9797
style={{ display: 'block' }}
9898
data-ad-format="fluid"
99-
data-ad-layout-key="-6u+e7+18-4k+8t"
100-
data-ad-client="ca-pub-5574866530496701"
101-
data-ad-slot="3828701581"
99+
data-ad-layout-key="-6c+ce+2v-x+66"
100+
data-ad-client="ca-pub-9161852896103498"
101+
data-ad-slot="2793890198"
102102
></ins>
103103
)}
104104
{/* {isMobile ? (

src/containers/post/HorizontalBanner.tsx

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@ import styled from 'styled-components';
33
import VelogResponsive from '../../components/velog/VelogResponsive';
44
import gtag from '../../lib/gtag';
55

6-
function HorizontalBanner() {
6+
type Props = {
7+
isDisplayAd?: boolean;
8+
};
9+
10+
function HorizontalBanner({ isDisplayAd = false }: Props) {
711
useEffect(() => {
812
(window.adsbygoogle = window.adsbygoogle || []).push({});
913
}, []);
@@ -14,14 +18,25 @@ function HorizontalBanner() {
1418

1519
return (
1620
<StyledResponsive onClick={onClick}>
17-
<ins
18-
className="adsbygoogle"
19-
style={{ display: 'block', textAlign: 'center' }}
20-
data-ad-layout="in-article"
21-
data-ad-format="fluid"
22-
data-ad-client="ca-pub-9161852896103498"
23-
data-ad-slot="6869845586"
24-
></ins>
21+
{isDisplayAd ? (
22+
<ins
23+
className="adsbygoogle"
24+
style={{ display: 'block', textAlign: 'center' }}
25+
data-ad-client="ca-pub-9161852896103498"
26+
data-ad-slot="5950320973"
27+
data-ad-format="auto"
28+
data-full-width-responsive="true"
29+
></ins>
30+
) : (
31+
<ins
32+
className="adsbygoogle"
33+
style={{ display: 'block', textAlign: 'center' }}
34+
data-ad-layout="in-article"
35+
data-ad-format="fluid"
36+
data-ad-client="ca-pub-9161852896103498"
37+
data-ad-slot="6869845586"
38+
></ins>
39+
)}
2540
</StyledResponsive>
2641
);
2742
}

src/containers/post/PostViewer.tsx

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -210,14 +210,24 @@ const PostViewer: React.FC<PostViewerProps> = ({
210210
if (isOwnPost) return false;
211211
if (!isVeryOld) return false;
212212
return true;
213-
}, [data, userId]);
213+
}, [data?.post, userId]);
214+
215+
const shouldShowFooterBanner = useMemo(() => {
216+
if (shouldShowBanner) return false;
217+
if (!data?.post) return false;
218+
if (userId) return false;
219+
return true;
220+
}, [userId, data?.post]);
214221

215222
useEffect(() => {
216223
if (!data?.post?.id) return;
217224
if (!shouldShowBanner) return;
218225
gtag('event', 'banner_view');
219226
console.log('banner_view');
220-
}, [data, shouldShowBanner]);
227+
if (userId) {
228+
gtag('event', 'banner_view_user');
229+
}
230+
}, [data?.post?.id, shouldShowBanner, userId]);
221231

222232
const onRemove = async () => {
223233
if (!data || !data.post) return;
@@ -441,37 +451,14 @@ const PostViewer: React.FC<PostViewerProps> = ({
441451
/>
442452
</UserProfileWrapper>
443453
<LinkedPostList linkedPosts={post.linked_posts} />
444-
{/* {showRecommends && userId === null && !isVeryOld && (
445-
<RelatedPostsForGuest
446-
postId={post.id}
447-
showAds={
448-
false
449-
// !isVeryOld &&
450-
// Date.now() - new Date(post.released_at).getTime() >
451-
// 1000 * 60 * 60 * 24 * 21
452-
}
453-
/>
454-
)} */}
455454
{shouldShowBanner && isContentLongEnough ? <HorizontalBanner /> : null}
456-
455+
{shouldShowFooterBanner ? <HorizontalBanner isDisplayAd /> : null}
457456
<PostComments
458457
count={post.comments_count}
459458
comments={post.comments}
460459
postId={post.id}
461460
ownPost={post.user.id === userId}
462461
/>
463-
{/* {showRecommends && (userId !== null || isVeryOld) && (
464-
<RelatedPost
465-
postId={post.id}
466-
showAds={
467-
false
468-
// !isVeryOld &&
469-
// post.user.id !== userId &&
470-
// Date.now() - new Date(post.released_at).getTime() >
471-
// 1000 * 60 * 60 * 24 * 30
472-
}
473-
/>
474-
)} */}
475462
{showRecommends ? (
476463
<RelatedPost postId={post.id} showAds={post?.user.id !== userId} />
477464
) : null}

src/containers/post/RelatedPost.tsx

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,19 +39,12 @@ function RelatedPost({
3939
const cloned: (PartialPost | undefined)[] = [
4040
...data.post.recommended_posts,
4141
];
42-
// get random number between 0 and length of array
43-
const randomIndex = () => Math.floor(Math.random() * 8);
42+
// get random number between 0 and 3
43+
const randomIndex = () => Math.floor(Math.random() * 3);
4444
const firstAdIndex = randomIndex();
45-
const secondAdIndex = (() => {
46-
let index = randomIndex();
47-
while (index === firstAdIndex) {
48-
index = randomIndex();
49-
}
50-
return index;
51-
})();
5245

5346
cloned[firstAdIndex] = undefined;
54-
cloned[secondAdIndex] = undefined;
47+
5548
return cloned;
5649
}, [data, showAds, adBlocked]);
5750

0 commit comments

Comments
 (0)