Files
kovakyazilim/components/consent-init.tsx
T
Ege Can Komur 8b4129c233 fix: Pexels image domain + ConsentInit'i statik script src'e taşı
İki sorun düzeltildi:

1) next.config.ts'e images.pexels.com (+ unsplash) eklendi
   - Mevcut 6 referans projesinde Pexels görsel URL'leri var
   - 'Invalid src prop on next/image' hatası giderildi
   - images.unsplash.com da eklendi (gelecekte kullanım için)

2) ConsentInit artık /public/consent-default.js'i src ile yüklüyor
   - React 19 + Next.js 16'da inline <script>{code}</script> ve
     <script dangerouslySetInnerHTML> her ikisi de 'Encountered a script
     tag while rendering React component' warning'i üretiyor
   - Statik dosya + <script src> pattern'i React'ın temiz şekilde
     kabul ettiği yöntem — warning yok, davranış aynı
   - GTM de aynı şekilde async src kullanıyor (önceki inline snippet
     yerine direkt GTM URL'i)
   - Consent default hala synchronous (script src defer/async olmadan)
     — gtag('consent','default') hiçbir analytics yüklenmeden çalışır
   - noscript iframe fallback korundu
2026-05-20 18:53:55 +03:00

34 lines
981 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* Google Consent Mode v2 — default consent state denied'da.
* Consent default ayarı `/public/consent-default.js`'den senkron yüklenir
* (script src ile — React'ın inline script warning'inden kaçınmak için).
*
* GTM script'i sadece gtm_id varsa yüklenir, aynı src pattern'i kullanır.
*/
export function ConsentInit({ gtmId }: { gtmId?: string | null }) {
return (
<>
{/* Default consent — synchronous, runs before any other JS */}
<script src="/consent-default.js" />
{/* GTM */}
{gtmId && (
<>
<script
async
src={`https://www.googletagmanager.com/gtm.js?id=${gtmId}`}
/>
<noscript>
<iframe
src={`https://www.googletagmanager.com/ns.html?id=${gtmId}`}
height="0"
width="0"
style={{ display: "none", visibility: "hidden" }}
/>
</noscript>
</>
)}
</>
);
}