mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
cleanup, add sorting
This commit is contained in:
@@ -2,7 +2,6 @@ import { Product } from '@commerce/types'
|
||||
import { getConfig, SwellConfig } from '../api'
|
||||
import fetchAllProducts from '../api/utils/fetch-all-products'
|
||||
import { ProductEdge } from '../schema'
|
||||
import getAllProductsPathsQuery from '../utils/queries/get-all-products-paths-query'
|
||||
|
||||
type ProductPath = {
|
||||
path: string
|
||||
@@ -21,17 +20,18 @@ const getAllProductPaths = async (options?: {
|
||||
config?: SwellConfig
|
||||
preview?: boolean
|
||||
}): Promise<ReturnType> => {
|
||||
let { config, variables = { first: 250 } } = options ?? {}
|
||||
let { config, variables = { limit: 100 } } = options ?? {}
|
||||
config = getConfig(config)
|
||||
|
||||
const products = await fetchAllProducts({
|
||||
config,
|
||||
query: getAllProductsPathsQuery,
|
||||
query: 'products',
|
||||
method: 'list',
|
||||
variables,
|
||||
})
|
||||
|
||||
return {
|
||||
products: products?.map(({ node: { handle } }: ProductEdge) => ({
|
||||
products: products?.map(({ slug: handle }) => ({
|
||||
node: {
|
||||
path: `/${handle}`,
|
||||
},
|
||||
|
Reference in New Issue
Block a user