diff --git a/components/layout/footer-menu.tsx b/components/layout/footer-menu.tsx index 444406294..2354f456c 100644 --- a/components/layout/footer-menu.tsx +++ b/components/layout/footer-menu.tsx @@ -2,6 +2,7 @@ import clsx from 'clsx'; import { Menu } from 'lib/shopify/types'; +import { RemoveTheDomainFromUrl } from 'lib/utils'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { useEffect, useState } from 'react'; @@ -17,7 +18,7 @@ const FooterMenuItem = ({ item }: { item: Menu }) => { return (
  • (
  • {item.title} diff --git a/lib/utils.ts b/lib/utils.ts index 69b76d29b..29c3e13e3 100644 --- a/lib/utils.ts +++ b/lib/utils.ts @@ -1,4 +1,5 @@ import { ReadonlyURLSearchParams } from 'next/navigation'; +const { SHOPIFY_STORE_DOMAIN } = process.env; export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyURLSearchParams) => { const paramsString = params.toString(); @@ -7,6 +8,13 @@ export const createUrl = (pathname: string, params: URLSearchParams | ReadonlyUR return `${pathname}${queryString}`; }; +export const RemoveTheDomainFromUrl = (url: string) => { + const lowercaseString = `https://${SHOPIFY_STORE_DOMAIN}`.toLowerCase(); + const modifiedUrl = url.replace(lowercaseString, ''); + + return modifiedUrl; +}; + export const ensureStartsWith = (stringToCheck: string, startsWith: string) => stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;