Searching.ton
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
639 B

2 years ago
import { gSSP } from "app/blitz-server"
import React from "react"
2 years ago
export interface ContextParamsServer {
2 years ago
cookies: Record<string, string | undefined>
}
interface Props {
2 years ago
props: ContextParamsServer
2 years ago
}
2 years ago
export interface ContextParams {
theme: string;
setTheme: (theme:'dark'| 'light')=> void;
}
export const serverSideProps = (pagePropsFunction?:()=>{}) => async ({ ctx, req }): Promise<Props> => {
const pageProps = await pagePropsFunction?.() || {};
2 years ago
return {
props: {
2 years ago
...pageProps,
2 years ago
cookies: req.cookies,
},
}
}
export const ServerSidePropsContext = React.createContext<ContextParams>({ cookies: {} })