= ({ product, className, variant = 'default' }) => {
const rootClassName = cn('w-full group relative overflow-hidden', className);
- const t = useTranslations('routes');
- const locale = useLocale();
+ console.log(product);
return (
{
+ 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
\ No newline at end of file
diff --git a/helpers/getQueryFromSlug.ts b/helpers/get-query-from-slug.ts
similarity index 70%
rename from helpers/getQueryFromSlug.ts
rename to helpers/get-query-from-slug.ts
index 6f079c5e6..70d909a1f 100644
--- a/helpers/getQueryFromSlug.ts
+++ b/helpers/get-query-from-slug.ts
@@ -1,14 +1,12 @@
-import { groq } from 'next-sanity'
import {
categoryQuery,
- homePageQuery,
pageQuery,
productQuery
-} from '../lib/sanity/queries'
+} from '@/lib/sanity/queries'
+import { groq } from 'next-sanity'
const getQueryFromSlug = (slugArray: string[], locale: string) => {
const docQuery: { [index: string]: string } = {
- 'homePage': groq`${homePageQuery}`,
'product': groq`${productQuery}`,
'category': groq`${categoryQuery}`,
'page': groq`${pageQuery}`,
@@ -16,21 +14,15 @@ const getQueryFromSlug = (slugArray: string[], locale: string) => {
let docType = ''
- if (!slugArray) {
- return {
- docType: 'home',
- queryParams: {locale: locale},
- query: docQuery.homePage,
- }
- }
-
const [slugStart] = slugArray
// We now have to re-combine the slug array to match our slug in Sanity.
- let queryParams = {
- slug: `/${slugArray.join('/')}`,
+ const queryParams = {
+ slug: `/${slugArray.join("/")}`,
locale: locale
- }
+ };
+
+ console.log("Query Params:", queryParams)
if (slugStart === `produkt` || slugStart === `product`) {
docType = `product`
diff --git a/next.config.js b/next.config.js
index 96fd5636a..b387ba00c 100644
--- a/next.config.js
+++ b/next.config.js
@@ -7,16 +7,6 @@ module.exports = withBundleAnalyzer(
{
async rewrites() {
return [
- {
- source: '/en/product/:slug',
- destination: '/en/produkt/:slug',
- locale: false
- },
- {
- source: '/en/category/:slug',
- destination: '/en/kategori/:slug',
- locale: false
- },
{
source: '/en/search',
destination: '/en/sok',