8b4129c233
İ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
34 lines
981 B
TypeScript
34 lines
981 B
TypeScript
/**
|
||
* 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>
|
||
</>
|
||
)}
|
||
</>
|
||
);
|
||
}
|