Skip to content

Commit fe603fa

Browse files
committed
feat: restores banner
1 parent 347544c commit fe603fa

File tree

3 files changed

+44
-11
lines changed

3 files changed

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

src/containers/post/PostViewer.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,8 @@ import { toast } from 'react-toastify';
3535
import MobileLikeButton from '../../components/post/MobileLikeButton';
3636
import RelatedPost from './RelatedPost';
3737
import optimizeImage from '../../lib/optimizeImage';
38-
import RelatedPostsForGuest from './RelatedPostsForGuest';
39-
import HorizontalAd from './HorizontalAd';
4038
import { useSetShowFooter } from '../../components/velog/VelogPageTemplate';
39+
import HorizontalBanner from './HorizontalBanner';
4140

4241
const UserProfileWrapper = styled(VelogResponsive)`
4342
margin-top: 16rem;
@@ -323,7 +322,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
323322

324323
const isVeryOld =
325324
Date.now() - new Date(post.released_at).getTime() >
326-
1000 * 60 * 60 * 24 * 365;
325+
1000 * 60 * 60 * 24 * 180;
327326

328327
const url = `https://velog.io/@${username}/${post.url_slug}`;
329328

@@ -389,6 +388,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
389388
/>
390389
}
391390
/>
391+
{userId === null && isVeryOld ? <HorizontalBanner /> : null}
392392
<PostContent isMarkdown={post.is_markdown} body={post.body} />
393393
<UserProfileWrapper>
394394
<UserProfile
@@ -400,7 +400,7 @@ const PostViewer: React.FC<PostViewerProps> = ({
400400
/>
401401
</UserProfileWrapper>
402402
<LinkedPostList linkedPosts={post.linked_posts} />
403-
{showRecommends && userId === null && !isVeryOld && (
403+
{/* {showRecommends && userId === null && !isVeryOld && (
404404
<RelatedPostsForGuest
405405
postId={post.id}
406406
showAds={
@@ -410,15 +410,18 @@ const PostViewer: React.FC<PostViewerProps> = ({
410410
// 1000 * 60 * 60 * 24 * 21
411411
}
412412
/>
413-
)}
414-
{/* {isVeryOld && userId === null && <HorizontalAd />} */}
413+
)} */}
414+
{userId === null && isVeryOld && post.body.length > 300 ? (
415+
<HorizontalBanner />
416+
) : null}
417+
415418
<PostComments
416419
count={post.comments_count}
417420
comments={post.comments}
418421
postId={post.id}
419422
ownPost={post.user.id === userId}
420423
/>
421-
{showRecommends && (userId !== null || isVeryOld) && (
424+
{/* {showRecommends && (userId !== null || isVeryOld) && (
422425
<RelatedPost
423426
postId={post.id}
424427
showAds={
@@ -429,7 +432,8 @@ const PostViewer: React.FC<PostViewerProps> = ({
429432
// 1000 * 60 * 60 * 24 * 30
430433
}
431434
/>
432-
)}
435+
)} */}
436+
{showRecommends ? <RelatedPost postId={post.id} showAds={false} /> : null}
433437
</PostViewerProvider>
434438
);
435439
};

src/index.server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ const proxyMiddleware = proxy(
2424
app.use(router.routes()).use(router.allowedMethods());
2525
app.use(ssrMiddleware);
2626
app.use(proxyMiddleware);
27-
// router.get('/ads.txt', (ctx) => {
28-
// ctx.body = `google.com, pub-5574866530496701, DIRECT, f08c47fec0942fa0`;
29-
// });
27+
router.get('/ads.txt', (ctx) => {
28+
ctx.body = `google.com, pub-9161852896103498, DIRECT, f08c47fec0942fa0`;
29+
});
3030
// router.post('/graphql', proxyMiddleware);
3131

3232
app.listen(3001, () => {

0 commit comments

Comments
 (0)