mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 03:31:23 +00:00
fix code
This commit is contained in:
@@ -3,7 +3,11 @@ import { Provider, VendureConfig } from '..'
|
||||
import { GetAllBlogsQuery,BlogList } from '../../schema'
|
||||
import { getAllBlogsQuery } from '../../utils/queries/get-all-blog-query'
|
||||
|
||||
export type BlogVariables = { take?: number,skip?:number }
|
||||
export type BlogVariables = {
|
||||
excludeBlogIds?: string[],
|
||||
take?: number,
|
||||
skip?:number
|
||||
}
|
||||
|
||||
export default function getAllBlogsOperation({
|
||||
commerce,
|
||||
@@ -24,8 +28,10 @@ export default function getAllBlogsOperation({
|
||||
config?: Partial<VendureConfig>
|
||||
preview?: boolean
|
||||
} = {}): Promise<{ blogs: GetAllBlogsQuery | any[] ,totalItems?:number }> {
|
||||
console.log(vars.excludeBlogIds)
|
||||
const config = commerce.getConfig(cfg)
|
||||
const variables = {
|
||||
excludeBlogIds: vars.excludeBlogIds,
|
||||
options: {
|
||||
take: vars.take,
|
||||
skip: vars.skip,
|
||||
@@ -34,7 +40,6 @@ export default function getAllBlogsOperation({
|
||||
const { data } = await config.fetch<GetAllBlogsQuery>(query, {
|
||||
variables,
|
||||
})
|
||||
|
||||
return {
|
||||
blogs: data?.blogs?.items?.map((val:BlogList)=>({
|
||||
id: val.id,
|
||||
@@ -42,7 +47,11 @@ export default function getAllBlogsOperation({
|
||||
imageSrc: val.featuredAsset?.preview ?? null,
|
||||
slug: val.translations[0]?.slug,
|
||||
description: val.translations[0]?.description,
|
||||
isHidden: val.isHidden
|
||||
isPublish: val.isPublish,
|
||||
isFeatured: val.isFeatured,
|
||||
authorName: val.authorName,
|
||||
authorAvatarAsset : val.authorAvatarAsset?.preview,
|
||||
createdAt: val.createdAt
|
||||
})),
|
||||
totalItems: data?.blogs?.totalItems || null
|
||||
}
|
||||
|
Reference in New Issue
Block a user