File size: 4,117 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
import {
MetaFunction,
LinksFunction,
json,
LoaderFunctionArgs,
ActionFunctionArgs,
} from '@vercel/remix'
import {
Links,
Meta,
Outlet,
Scripts,
ScrollRestoration,
useLoaderData,
} from '@remix-run/react'
import { Analytics } from '@vercel/analytics/react'
import { WidgetPlausible } from './components/Widgets/WidgetPlausible'
import { lightThemeClass } from './styles/light-theme.css'
import global from './styles/global.css?url'
import docusearch from '@docsearch/css/dist/style.css?url'
import { getTheme, setTheme } from './helpers/theme.server'
import { darkThemeClass } from './styles/dark-theme.css'
import { ClientHintCheck, getHints } from './components/Site/SiteClientHints'
import { useTheme } from './hooks/useTheme'
import { SiteFooter } from './components/Site/SiteFooter'
export const meta: MetaFunction = () => {
return [
{ title: 'react-spring' },
{
name: 'description',
content:
'Bring your components to life with simple spring animation primitives for React',
},
{ property: 'og:site_name', content: 'React Spring' },
{ property: 'og:title', content: 'React Spring' },
{
property: 'og:description',
content:
'Bring your components to life with simple spring animation primitives for React',
},
{ property: 'og:image', content: 'https://www.react-spring.dev/share.jpg' },
{ property: 'og:type', content: 'website' },
{ property: 'og:image:width', content: '1200' },
{ property: 'og:image:height', content: '630' },
{ property: 'og:url', content: 'https://www.react-spring.dev' },
{ property: 'twitter:card', content: 'summary_large_image' },
{ property: 'twitter:domain', content: 'react-spring.dev' },
{ property: 'twitter:url', content: 'https://www.react-spring.dev' },
{ property: 'twitter:title', content: 'React Spring' },
{
property: 'twitter:description',
content:
'Bring your components to life with simple spring animation primitives for React',
},
{
property: 'twitter:image',
content: 'https://www.react-spring.dev/share.jpg',
},
]
}
export const links: LinksFunction = () => [
{ rel: 'stylesheet', href: docusearch },
{ rel: 'stylesheet', href: global },
{ rel: 'stylesheet', href: 'https://rsms.me/inter/inter.css' },
{ rel: 'preconnect', href: 'https://fonts.googleapis.com' },
{ rel: 'preconnect', href: 'https://fonts.gstatic.com' },
{
rel: 'stylesheet',
href: 'https://fonts.googleapis.com/css2?family=Space+Mono:ital,wght@0,400;0,700;1,400&display=swap',
},
]
export const loader = ({ request }: LoaderFunctionArgs) => {
return json({
requestInfo: {
hints: getHints(request),
userPrefs: {
theme: getTheme(request),
},
},
ENV: {
ENABLE_PLAUSIBLE: process.env.ENABLE_PLAUSIBLE,
ALGOLIA_APP_ID: process.env.ALGOLIA_APP_ID,
ALGOLIA_API_KEY: process.env.ALGOLIA_API_KEY,
ENABLE_CARBON: process.env.ENABLE_CARBON,
},
})
}
export async function action({ request }: ActionFunctionArgs) {
const body = await request.json()
const theme = body.theme ?? 'light'
const responseInit = {
headers: { 'set-cookie': setTheme(theme) },
}
return json({ ok: true }, responseInit)
}
export function Layout({ children }: { children: React.ReactNode }) {
const data = useLoaderData<typeof loader>()
const theme = useTheme()
return (
<html lang="en">
<head>
<ClientHintCheck />
<meta charSet="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<Meta />
<Links />
<WidgetPlausible />
</head>
<body className={theme === 'light' ? lightThemeClass : darkThemeClass}>
{children}
<SiteFooter />
<script
dangerouslySetInnerHTML={{
__html: `window.env = ${JSON.stringify(data.ENV)}`,
}}
/>
)
}
export default function App() {
return
}
|