mirror of
https://github.com/vercel/commerce.git
synced 2025-09-09 09:20:16 +00:00
.github
.vscode
packages
site
assets
components
config
lib
api
click-outside
hooks
colors.ts
focus-trap.tsx
get-slug.ts
range-map.ts
search-props.tsx
search.tsx
to-pixels.ts
usage-warns.ts
pages
public
.env.template
.eslintrc
.gitignore
.npmrc
.prettierignore
.prettierrc
commerce-config.js
commerce.config.json
global.d.ts
next-env.d.ts
next.config.js
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
.editorconfig
.gitignore
.prettierignore
.prettierrc
README.md
license.md
package.json
pnpm-lock.yaml
pnpm-workspace.yaml
turbo.json
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
|
|
>
|