File tree 4 files changed +90
-16
lines changed
4 files changed +90
-16
lines changed Original file line number Diff line number Diff line change 2
2
< html lang ="kr " data-theme ="light ">
3
3
< head >
4
4
< meta charset ="utf-8 " />
5
+ < meta name ="google-adsense-account " content ="ca-pub-8658385917169302 " />
5
6
< meta
6
7
name ="google-site-verification "
7
8
content ="x96FdMXm-uHwvLPsY__UXOIvT3CNgHMApLx5Ki6TZ9w "
16
17
href ="https://fonts.googleapis.com/icon?family=Material+Icons "
17
18
rel ="stylesheet "
18
19
/>
20
+ < script
21
+ async
22
+ src ="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-8658385917169302 "
23
+ crossorigin ="anonymous "
24
+ > </ script >
19
25
< title > Speed Coder</ title >
20
26
</ head >
21
27
< body onpaste ="return false ">
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import fetcher from "../utils/fetcher";
2
2
import { useState , useEffect , useCallback } from "react" ;
3
3
import { useInView } from "react-intersection-observer" ;
4
4
import LeaderBoardContents from "./LeaderBoardContents" ;
5
+ import InFeedAdvertise from "./advertises/InFeedAdvertise" ;
5
6
6
7
export default function LeaderBoard ( { daynight } ) {
7
8
const [ prev , prevInView ] = useInView ( ) ; // 무한 스크롤용 ref - 이전
@@ -62,26 +63,38 @@ export default function LeaderBoard({ daynight }) {
62
63
</ ul >
63
64
) : (
64
65
< ul className = "sidebarsection-rank" >
65
- { items . map ( ( s , i ) => {
66
- // if (i === 2) {
67
- // return (
68
- // <li key={s._id} ref={prev}>
69
- // <LeaderBoardContents s={s} />
70
- // </li>
71
- // );
72
- if ( i === items . length - 1 ) {
66
+ { items
67
+ . map ( ( s , i ) => {
68
+ // if (i === 2) {
69
+ // return (
70
+ // <li key={s._id} ref={prev}>
71
+ // <LeaderBoardContents s={s} />
72
+ // </li>
73
+ // );
74
+ if ( i === items . length - 1 ) {
75
+ return (
76
+ < li key = { s . _id } ref = { next } >
77
+ < LeaderBoardContents s = { s } />
78
+ </ li >
79
+ ) ;
80
+ }
73
81
return (
74
- < li key = { s . _id } ref = { next } >
82
+ < li key = { s . _id } >
75
83
< LeaderBoardContents s = { s } />
76
84
</ li >
77
85
) ;
78
- }
79
- return (
80
- < li key = { s . _id } >
81
- < LeaderBoardContents s = { s } />
82
- </ li >
83
- ) ;
84
- } ) }
86
+ } )
87
+ . reduce ( ( acc , curr , i ) => {
88
+ if ( i === 3 ) {
89
+ acc . push (
90
+ < li key = "advertise" >
91
+ < InFeedAdvertise />
92
+ </ li >
93
+ ) ;
94
+ }
95
+ acc . push ( curr ) ;
96
+ return acc ;
97
+ } , [ ] ) }
85
98
{ loading && (
86
99
< li >
87
100
< ul >
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { useEffect, useState } from "react";
2
2
import Debug from "./Debug" ;
3
3
import LeaderBoard from "./LeaderBoard" ;
4
4
import IconGenerator from "./IconGenerator" ;
5
+ import InFeedAdvertise from "./advertises/InFeedAdvertise" ;
5
6
6
7
export default function Sidebar ( props ) {
7
8
const [ filestate , setFilestate ] = useState ( "hello.py" ) ;
Original file line number Diff line number Diff line change
1
+ import { useEffect } from "react" ;
2
+
3
+ const InFeedAdvertise = ( {
4
+ className = "adsbygoogle" ,
5
+ client = "ca-pub-8658385917169302" ,
6
+ slot = "1562420452" ,
7
+ format = "fluid" ,
8
+ layoutKey = "-fp+68-11-df+sd" ,
9
+ } ) => {
10
+ useEffect ( ( ) => {
11
+ if ( process . env . NODE_ENV === "production" )
12
+ try {
13
+ ( window . adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ;
14
+ console . log ( "Advertise is pushed" ) ;
15
+ } catch ( e ) {
16
+ console . error ( "AdvertiseError" , e ) ;
17
+ }
18
+ } , [ ] ) ;
19
+
20
+ //production이 아닌 경우 대체 컴포넌트 표시
21
+ if ( process . env . NODE_ENV !== "production" )
22
+ return (
23
+ < div
24
+ style = { {
25
+ background : "#8aff8a" ,
26
+ color : "black" ,
27
+ fontSize : "18px" ,
28
+ fontWeight : "bold" ,
29
+ textAlign : "center" ,
30
+ padding : "16px" ,
31
+ } }
32
+ >
33
+ 광고 표시 영역
34
+ </ div >
35
+ ) ;
36
+ //production인 경우 구글 광고 표시
37
+ return (
38
+ < ins
39
+ className = { className }
40
+ style = { {
41
+ overflowX : "auto" ,
42
+ overflowY : "hidden" ,
43
+ display : "block" ,
44
+ textAlign : "center" ,
45
+ } }
46
+ data-ad-client = { client }
47
+ data-ad-slot = { slot }
48
+ data-ad-format = { format }
49
+ data-ad-layout-key = { layoutKey }
50
+ />
51
+ ) ;
52
+ } ;
53
+
54
+ export default InFeedAdvertise ;
You can’t perform that action at this time.
0 commit comments