mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
29 lines
735 B
TypeScript
29 lines
735 B
TypeScript
import type { GetStaticPropsContext, InferGetStaticPropsType } from 'next'
|
|
|
|
import commerce from '@lib/api/commerce'
|
|
|
|
export async function getSearchStaticProps({
|
|
preview,
|
|
locale,
|
|
locales,
|
|
}: GetStaticPropsContext) {
|
|
const config = { locale, locales }
|
|
const pagesPromise = commerce.getAllPages({ config, preview })
|
|
const siteInfoPromise = commerce.getSiteInfo({ config, preview })
|
|
const { pages } = await pagesPromise
|
|
const { categories, brands, navigation } = await siteInfoPromise
|
|
return {
|
|
props: {
|
|
pages,
|
|
categories,
|
|
brands,
|
|
...(navigation ? { navigation } : {}),
|
|
},
|
|
revalidate: 200,
|
|
}
|
|
}
|
|
|
|
export type SearchPropsType = InferGetStaticPropsType<
|
|
typeof getSearchStaticProps
|
|
>
|