mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
Merge pull request #88 from KieIO/feature/m4-get-blog-list
Feature/m4 get blog list
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { Cart } from '@commerce/types/cart'
|
||||
import { ProductCard, Product } from '@commerce/types/product'
|
||||
import { CartFragment, SearchResultFragment,Favorite } from '../schema'
|
||||
import { CartFragment, SearchResultFragment,Favorite, BlogList } from '../schema'
|
||||
|
||||
export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
|
||||
return {
|
||||
@@ -83,4 +83,19 @@ export function normalizeProductCard(product: Product): ProductCard {
|
||||
facetValueIds: product.facetValueIds,
|
||||
collectionIds: product.collectionIds,
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeBlogList(blog: BlogList) {
|
||||
return {
|
||||
id: blog.id,
|
||||
title: blog.translations[0]?.title,
|
||||
imageSrc: blog.featuredAsset?.preview ?? null,
|
||||
slug: blog.translations[0]?.slug,
|
||||
description: blog.translations[0]?.description,
|
||||
isPublish: blog.isPublish,
|
||||
isFeatured:blog.isFeatured,
|
||||
authorName: blog.authorName,
|
||||
authorAvatarAsset : blog.authorAvatarAsset?.preview,
|
||||
createdAt: blog.createdAt
|
||||
}
|
||||
}
|
26
framework/vendure/utils/queries/get-all-blog-query.ts
Normal file
26
framework/vendure/utils/queries/get-all-blog-query.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
export const getAllBlogsQuery = /* GraphQL */ `
|
||||
query GetBlogs($excludeBlogIds: [ID]!, $options: BlogListOptions) {
|
||||
blogs(excludeBlogIds: $excludeBlogIds, options: $options) {
|
||||
totalItems
|
||||
items {
|
||||
id
|
||||
isPublish
|
||||
isFeatured
|
||||
authorName
|
||||
createdAt
|
||||
authorAvatarAsset{
|
||||
preview
|
||||
}
|
||||
featuredAsset {
|
||||
preview
|
||||
}
|
||||
translations {
|
||||
title
|
||||
slug
|
||||
description
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
25
framework/vendure/utils/queries/get-featued-query.ts
Normal file
25
framework/vendure/utils/queries/get-featued-query.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
export const getFeatuedBlogsQuery = /* GraphQL */ `
|
||||
query GetFeaturedBlogs($options: BlogListOptions) {
|
||||
featuredBlogs( options: $options){
|
||||
items {
|
||||
id
|
||||
isPublish
|
||||
isFeatured
|
||||
authorName
|
||||
createdAt
|
||||
authorAvatarAsset{
|
||||
preview
|
||||
}
|
||||
featuredAsset {
|
||||
preview
|
||||
}
|
||||
translations {
|
||||
title
|
||||
slug
|
||||
description
|
||||
content
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
Reference in New Issue
Block a user