mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
Adding more data
This commit is contained in:
parent
aec233bf54
commit
95d45b3030
@ -1,8 +1,8 @@
|
||||
import getCategories from '../../utils/get-categories'
|
||||
import getVendors, { Brands } from '../../utils/get-vendors'
|
||||
import { Provider, SwellConfig } from '../'
|
||||
import { OperationContext } from '@commerce/api/operations'
|
||||
import { Category } from '@commerce/types/site'
|
||||
import type { OperationContext } from '@commerce/api/operations'
|
||||
import type { Category } from '@commerce/types/site'
|
||||
|
||||
export type GetSiteInfoResult<
|
||||
T extends { categories: any[]; brands: any[] } = {
|
||||
|
@ -1,33 +0,0 @@
|
||||
import getCategories from '../utils/get-categories'
|
||||
import getVendors, { Brands } from '../utils/get-vendors'
|
||||
import { Category } from '@commerce/types'
|
||||
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 categoriesPromise = getCategories(config)
|
||||
const brandsPromise = getVendors(config)
|
||||
const categories = await categoriesPromise
|
||||
const brands = await brandsPromise
|
||||
|
||||
return {
|
||||
categories,
|
||||
brands,
|
||||
}
|
||||
}
|
||||
|
||||
export default getSiteInfo
|
@ -22,8 +22,8 @@
|
||||
"@components/*": ["components/*"],
|
||||
"@commerce": ["framework/commerce"],
|
||||
"@commerce/*": ["framework/commerce/*"],
|
||||
"@framework": ["framework/local"],
|
||||
"@framework/*": ["framework/local/*"]
|
||||
"@framework": ["framework/swell"],
|
||||
"@framework/*": ["framework/swell/*"]
|
||||
}
|
||||
},
|
||||
"include": ["next-env.d.ts", "**/*.d.ts", "**/*.ts", "**/*.tsx", "**/*.js"],
|
||||
@ -31,7 +31,6 @@
|
||||
"node_modules",
|
||||
"./framework/bigcommerce",
|
||||
"./framework/shopify",
|
||||
"./framework/swell",
|
||||
"./framework/vendure",
|
||||
"./framework/saleor"
|
||||
]
|
||||
|
Loading…
x
Reference in New Issue
Block a user