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 { data } = await config.fetch(getAllPagesQuery, { variables })
const pages = data.pages?.edges?.map( const pages = data.pages?.edges?.map(
({ node: { title: name, handle, ...node } }: PageEdge) => ({ ({ node: { title: name, slug, ...node } }: PageCountableEdge) => ({
...node, ...node,
url: `/${locale}/${handle}`, url: `/${locale}/${slug}`,
name, name,
}) })
) )

View File

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

View File

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

View File

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