fix: page/product properties

This commit is contained in:
Zaiste 2021-04-19 15:38:40 +02:00
parent 89f6c1ce76
commit 5402af4902
No known key found for this signature in database
GPG Key ID: 15DF7EBC7F2FFE35
4 changed files with 8 additions and 12 deletions

View File

@ -29,9 +29,9 @@ const getAllPages = async (options?: {
const { data } = await config.fetch(getAllPagesQuery, { variables })
const pages = data.pages?.edges?.map(
({ node: { title: name, handle, ...node } }: PageEdge) => ({
({ node: { title: name, slug, ...node } }: PageCountableEdge) => ({
...node,
url: `/${locale}/${handle}`,
url: `/${locale}/${slug}`,
name,
})
)

View File

@ -21,14 +21,14 @@ const getPage = async (options: {
const { data } = await config.fetch(getPageQuery, {
variables,
})
const page = data.node
const page = data.page
return {
page: page
? {
...page,
name: page.title,
url: `/${locale}/${page.handle}`,
url: `/${locale}/${page.slug}`,
}
: null,
}

View File

@ -33,7 +33,7 @@ const getAllProductPaths = async (options?: {
return {
products: products?.map(({ node: { slug } }: ProductCountableEdge) => ({
node: {
path: `/${handle}`,
path: `/${slug}`,
},
})),
}

View File

@ -1,13 +1,9 @@
export const getPageQuery = /* GraphQL */ `
query($id: ID!) {
node(id: $id) {
page(id: $id) {
id
... on Page {
title
handle
body
bodySummary
}
title
slug
}
}
`