mirror of
https://github.com/vercel/commerce.git
synced 2025-03-27 07:45:53 +00:00
32 lines
679 B
TypeScript
32 lines
679 B
TypeScript
import getCategories, { Category } from '../utils/get-categories'
|
|
import getVendors, { Brands } from '../utils/get-vendors'
|
|
|
|
import { getConfig, SwellConfig } from '../api'
|
|
|
|
export type GetSiteInfoResult<
|
|
T extends { categories: any[]; brands: any[] } = {
|
|
categories: Category[]
|
|
brands: Brands
|
|
}
|
|
> = T
|
|
|
|
const getSiteInfo = async (options?: {
|
|
variables?: any
|
|
config: SwellConfig
|
|
preview?: boolean
|
|
}): Promise<GetSiteInfoResult> => {
|
|
let { config } = options ?? {}
|
|
|
|
config = getConfig(config)
|
|
|
|
const categories = await getCategories(config)
|
|
const brands = await getVendors(config)
|
|
|
|
return {
|
|
categories,
|
|
brands,
|
|
}
|
|
}
|
|
|
|
export default getSiteInfo
|