Files
supabase/apps/www/pages/_app.tsx
Francesco Sansalvadore e76aa11508 homepage cleanup (#29295)
* new homepage logos marquee

* add products claim

* logos spacing

* dashboard table editor demo

* dashboard table editor demo

* dashboard recordings

* rls policies

* update hp frameworks

* add dataAPIs to homepage bento

* tweet section update

* padding

* hp products update

* new customer stories hp section

* height

* finish homepage details

* update logos

* fix database visual

* improve functions visual ux

* animate data-apis visual

* realtime visual update

* reduce-motion and update chatbase logo

* lighter heading paragraph

* improve video tabs components

* add priority to offsetted images

* video plays inline

* fix mobile tweets spacing

* smoll

* load video slightly before the component enters the viewport

* fix product pointer-events

* theme based and light weight dashboard video

* testimonials margin

* remove yellow tint from light mode recordings

* fix vitest window-matchMedia error

* fix vitest window-matchMedia error

* fix url type

* remove tweet
2024-09-17 11:07:38 +02:00

141 lines
4.2 KiB
TypeScript

import '@code-hike/mdx/styles'
import 'config/code-hike.scss'
import '../styles/index.css'
import { SessionContextProvider } from '@supabase/auth-helpers-react'
import { AuthProvider, IS_PROD, ThemeProvider, useTelemetryProps, useThemeSandbox } from 'common'
import { DefaultSeo } from 'next-seo'
import { AppProps } from 'next/app'
import Head from 'next/head'
import { useRouter } from 'next/router'
import { useEffect } from 'react'
import { SonnerToaster, themes } from 'ui'
import { CommandProvider } from 'ui-patterns/CommandMenu'
import { useConsent } from 'ui-patterns/ConsentToast'
import MetaFaviconsPagesRouter, {
DEFAULT_FAVICON_ROUTE,
DEFAULT_FAVICON_THEME_COLOR,
} from 'common/MetaFavicons/pages-router'
import { WwwCommandMenu } from '~/components/CommandMenu'
import { API_URL, APP_NAME, DEFAULT_META_DESCRIPTION, IS_PREVIEW } from '~/lib/constants'
import { post } from '~/lib/fetchWrapper'
import supabase from '~/lib/supabase'
import useDarkLaunchWeeks from '../hooks/useDarkLaunchWeeks'
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter()
const telemetryProps = useTelemetryProps()
const { consentValue, hasAcceptedConsent } = useConsent()
const IS_DEV = !IS_PROD && !IS_PREVIEW
const blockEvents = IS_DEV || !hasAcceptedConsent
useThemeSandbox()
function handlePageTelemetry(route: string) {
return post(`${API_URL}/telemetry/page`, {
referrer: document.referrer,
title: document.title,
route,
ga: {
screen_resolution: telemetryProps?.screenResolution,
language: telemetryProps?.language,
},
})
}
useEffect(() => {
if (blockEvents) return
function handleRouteChange(url: string) {
handlePageTelemetry(url)
}
// Listen for page changes after a navigation or when the query changes
router.events.on('routeChangeComplete', handleRouteChange)
return () => {
router.events.off('routeChangeComplete', handleRouteChange)
}
}, [router.events, consentValue])
useEffect(() => {
if (blockEvents) return
/**
* Send page telemetry on first page load
*/
if (router.isReady) {
handlePageTelemetry(router.asPath)
}
}, [router.isReady, consentValue])
const site_title = `${APP_NAME} | The Open Source Firebase Alternative`
const { basePath } = useRouter()
const isDarkLaunchWeek = useDarkLaunchWeeks()
const forceDarkMode = isDarkLaunchWeek
let applicationName = 'Supabase'
let faviconRoute = DEFAULT_FAVICON_ROUTE
let themeColor = DEFAULT_FAVICON_THEME_COLOR
if (router.asPath && router.asPath.includes('/launch-week/x')) {
applicationName = 'Supabase LWX'
faviconRoute = 'images/launchweek/lwx/favicon'
themeColor = 'FFFFFF'
}
return (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
<MetaFaviconsPagesRouter
applicationName={applicationName}
route={faviconRoute}
themeColor={themeColor}
includeManifest
includeMsApplicationConfig
includeRssXmlFeed
/>
<DefaultSeo
title={site_title}
description={DEFAULT_META_DESCRIPTION}
openGraph={{
type: 'website',
url: 'https://supabase.com/',
site_name: 'Supabase',
images: [
{
url: `https://supabase.com${basePath}/images/og/supabase-og.png`,
width: 800,
height: 600,
alt: 'Supabase Og Image',
},
],
}}
twitter={{
handle: '@supabase',
site: '@supabase',
cardType: 'summary_large_image',
}}
/>
<SessionContextProvider supabaseClient={supabase}>
<AuthProvider>
<ThemeProvider
themes={themes.map((theme) => theme.value)}
enableSystem
disableTransitionOnChange
forcedTheme={forceDarkMode ? 'dark' : undefined}
>
<CommandProvider>
<SonnerToaster position="top-right" />
<Component {...pageProps} />
<WwwCommandMenu />
</CommandProvider>
</ThemeProvider>
</AuthProvider>
</SessionContextProvider>
</>
)
}