File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,9 +66,16 @@ const AdBanner: React.FC<AdBannerProps> = ({
6666 }
6767 } ) ;
6868
69- if ( loaded && window . adsbygoogle ) {
69+ if ( loaded && window . adsbygoogle && adRef . current ) {
7070 // 광고 초기화 시도
7171 try {
72+ // 이미 초기화된 광고인지 확인
73+ const existingAd = adRef . current . querySelector ( '.adsbygoogle' ) ;
74+ if ( existingAd && existingAd . getAttribute ( 'data-adsbygoogle-status' ) ) {
75+ safeLog . info ( 'Ad already initialized for slot:' , slot ) ;
76+ return ;
77+ }
78+
7279 ( window . adsbygoogle = window . adsbygoogle || [ ] ) . push ( { } ) ;
7380 safeLog . info ( 'AdSense ad initialized for slot:' , slot ) ;
7481 } catch ( error ) {
@@ -111,6 +118,19 @@ const AdBanner: React.FC<AdBannerProps> = ({
111118 ) ;
112119 }
113120
121+ // 유효한 슬롯 ID인지 확인 (AdSense에서 생성한 슬롯 ID는 숫자로만 구성됨)
122+ const isValidSlot = / ^ \d + $ / . test ( slot ) ;
123+ if ( ! isValidSlot ) {
124+ safeLog . warn ( `Invalid AdSense slot format: ${ slot } . Slot should be numeric.` ) ;
125+ return (
126+ < div className = { `bg-yellow-50 border-2 border-dashed border-yellow-300 rounded-lg p-4 text-center ${ className } ` } style = { style } >
127+ < p className = "text-yellow-600 text-sm" > ⚠️ Invalid Ad Slot</ p >
128+ < p className = "text-xs text-yellow-500 mt-1" > Slot: { slot } </ p >
129+ < p className = "text-xs text-yellow-400 mt-2" > AdSense 슬롯 ID는 숫자여야 합니다</ p >
130+ </ div >
131+ ) ;
132+ }
133+
114134 return (
115135 < div className = { `ad-container ${ className } ` } style = { style } >
116136 < ins
Original file line number Diff line number Diff line change @@ -197,8 +197,8 @@ const Index = () => {
197197 { /* 사이드바 광고 */ }
198198 < AnalyticsErrorBoundary >
199199 < AdBanner
200- slot = "sidebar-ad "
201- format = "rectangle "
200+ slot = "1234567890 "
201+ format = "auto "
202202 className = "w-full"
203203 style = { { minHeight : '250px' } }
204204 />
@@ -207,8 +207,8 @@ const Index = () => {
207207 { /* 두 번째 광고 */ }
208208 < AnalyticsErrorBoundary >
209209 < AdBanner
210- slot = "sidebar-ad-2 "
211- format = "rectangle "
210+ slot = "0987654321 "
211+ format = "auto "
212212 className = "w-full"
213213 style = { { minHeight : '250px' } }
214214 />
Original file line number Diff line number Diff line change @@ -148,8 +148,8 @@ const ToolPage = () => {
148148 < div className = "mt-8" >
149149 < AnalyticsErrorBoundary >
150150 < AdBanner
151- slot = "tool-bottom-banner "
152- format = "horizontal "
151+ slot = "1122334455 "
152+ format = "auto "
153153 className = "max-w-2xl mx-auto"
154154 style = { { minHeight : '250px' } }
155155 />
You can’t perform that action at this time.
0 commit comments