From c799a5f53db890c1a3a86f7200007950ea744729 Mon Sep 17 00:00:00 2001 From: Mandeep Tatla Date: Sun, 12 May 2024 11:59:57 +0930 Subject: [PATCH] Updated the footer to remove the domian url as it was causing the redirect to shopify domain --- components/layout/footer-menu.tsx | 3 +-- components/layout/footer.tsx | 4 +++- lib/utils.ts | 11 +++++++++++ 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/components/layout/footer-menu.tsx b/components/layout/footer-menu.tsx index 2354f456c..444406294 100644 --- a/components/layout/footer-menu.tsx +++ b/components/layout/footer-menu.tsx @@ -2,7 +2,6 @@ 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'; @@ -18,7 +17,7 @@ const FooterMenuItem = ({ item }: { item: Menu }) => { return (
  • 2023 ? `-${currentYear}` : ''); const skeleton = 'w-full h-6 animate-pulse rounded bg-neutral-200 dark:bg-neutral-700'; const menu = await getMenu('next-js-frontend-footer-menu'); + const updatedMenuLinks = RemoveTheDomainFromArray(menu); const copyrightName = COMPANY_NAME || SITE_NAME || ''; return ( @@ -35,7 +37,7 @@ export default async function Footer() { } > - +
    { return modifiedUrl; }; +export const RemoveTheDomainFromArray = (menu: any) => { + const lowercaseString = `https://${SHOPIFY_STORE_DOMAIN}`.toLowerCase(); + + const modifiedUrls = menu.map((item: any) => { + const modifiedPath = item.path.replace(lowercaseString, ''); + return { ...item, path: modifiedPath }; + }); + + return modifiedUrls; +}; + export const ensureStartsWith = (stringToCheck: string, startsWith: string) => stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;