mirror of
https://github.com/supabase/supabase.git
synced 2026-10-05 17:35:10 +03:00
* show cms blog posts in www * remove contentlayer from www * outputFileTracingExcludes * update remotePatterns * fetch cms posts server-side with revalidation * add cms env vars to turbo.json * add www env vars to turbo.json * include cms posts in www sitemap * add migration to remove image from cms post * update cms meta image mapping in www
22 lines
587 B
TypeScript
22 lines
587 B
TypeScript
'use client'
|
|
|
|
import { useEffect, useState } from 'react'
|
|
|
|
/**
|
|
* Hook to detect if the user is in Next.js Draft Mode
|
|
* Checks for the __prerender_bypass cookie that Next.js sets when draft mode is enabled
|
|
*/
|
|
export function useDraftMode() {
|
|
const [isDraftMode, setIsDraftMode] = useState(false)
|
|
|
|
useEffect(() => {
|
|
// Check if we're in the browser and if the draft mode cookie exists
|
|
if (typeof window !== 'undefined') {
|
|
const hasDraftCookie = document.cookie.includes('__prerender_bypass')
|
|
setIsDraftMode(hasDraftCookie)
|
|
}
|
|
}, [])
|
|
|
|
return isDraftMode
|
|
}
|