static path

main
Amir Hossein Moghiseh 2025-02-22 23:20:46 +03:30
parent c3e386a8a1
commit 04fdf51e7b
1 changed files with 32 additions and 0 deletions

View File

@ -79,6 +79,38 @@ const gql = `
}
`;
const gql_static = `
query Products($locale:I18NLocaleCode,$start:Int,$limit:Int) {
products(locale: $locale, pagination: { start: $start, limit: $limit }) {
slug
category {
slug
}
brand {
slug
}
}
}
`
export async function generateStaticParams() {
const { products } = await graphql(gql_static, {
"locale": "en",
"start": 0,
"limit": 1500
})
const params = [];
products.forEach((product) => {
params.push({ category: product.category.slug, slug: product.slug })
params.push({ category: product.brand.slug, slug: product.slug })
})
return params;
}
const getProduct = async (slug) => {
const { products } = await graphql(gql, {