mirror of
https://github.com/vercel/commerce.git
synced 2025-05-15 14:06:59 +00:00
26 lines
578 B
TypeScript
26 lines
578 B
TypeScript
const getParamsFromSlug = (slugArray: string[], locale: string) => {
|
|
let docType = ''
|
|
|
|
const [slugStart] = slugArray
|
|
|
|
// We now have to re-combine the slug array to match our slug in Sanity.
|
|
const queryParams = {
|
|
slug: `/${slugArray.join('/')}`,
|
|
locale: locale
|
|
}
|
|
|
|
if (slugStart === `produkt` || slugStart === `product`) {
|
|
docType = `product`
|
|
} else if (slugStart === `kategori` || slugStart === `category`) {
|
|
docType = `category`
|
|
} else {
|
|
docType = `page`
|
|
}
|
|
|
|
return {
|
|
docType,
|
|
queryParams,
|
|
}
|
|
}
|
|
|
|
export default getParamsFromSlug |