mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 15:36:58 +00:00
Updated the footer to remove the domian url as it was causing the redirect to shopify domain
This commit is contained in:
parent
8cd637e609
commit
c799a5f53d
@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import { Menu } from 'lib/shopify/types';
|
import { Menu } from 'lib/shopify/types';
|
||||||
import { RemoveTheDomainFromUrl } from 'lib/utils';
|
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { usePathname } from 'next/navigation';
|
import { usePathname } from 'next/navigation';
|
||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
@ -18,7 +17,7 @@ const FooterMenuItem = ({ item }: { item: Menu }) => {
|
|||||||
return (
|
return (
|
||||||
<li>
|
<li>
|
||||||
<Link
|
<Link
|
||||||
href={RemoveTheDomainFromUrl(item.path)}
|
href={item.path}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'block p-2 text-lg underline-offset-4 hover:text-black hover:underline md:inline-block md:text-sm dark:hover:text-neutral-300',
|
'block p-2 text-lg underline-offset-4 hover:text-black hover:underline md:inline-block md:text-sm dark:hover:text-neutral-300',
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@ import Link from 'next/link';
|
|||||||
import FooterMenu from 'components/layout/footer-menu';
|
import FooterMenu from 'components/layout/footer-menu';
|
||||||
import LogoSquare from 'components/logo-square';
|
import LogoSquare from 'components/logo-square';
|
||||||
import { getMenu } from 'lib/shopify';
|
import { getMenu } from 'lib/shopify';
|
||||||
|
import { RemoveTheDomainFromArray } from 'lib/utils';
|
||||||
import { Suspense } from 'react';
|
import { Suspense } from 'react';
|
||||||
|
|
||||||
const { COMPANY_NAME, SITE_NAME } = process.env;
|
const { COMPANY_NAME, SITE_NAME } = process.env;
|
||||||
@ -12,6 +13,7 @@ export default async function Footer() {
|
|||||||
const copyrightDate = 2023 + (currentYear > 2023 ? `-${currentYear}` : '');
|
const copyrightDate = 2023 + (currentYear > 2023 ? `-${currentYear}` : '');
|
||||||
const skeleton = 'w-full h-6 animate-pulse rounded bg-neutral-200 dark:bg-neutral-700';
|
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 menu = await getMenu('next-js-frontend-footer-menu');
|
||||||
|
const updatedMenuLinks = RemoveTheDomainFromArray(menu);
|
||||||
const copyrightName = COMPANY_NAME || SITE_NAME || '';
|
const copyrightName = COMPANY_NAME || SITE_NAME || '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -35,7 +37,7 @@ export default async function Footer() {
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<FooterMenu menu={menu} />
|
<FooterMenu menu={updatedMenuLinks} />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<div className="md:ml-auto">
|
<div className="md:ml-auto">
|
||||||
<a
|
<a
|
||||||
|
11
lib/utils.ts
11
lib/utils.ts
@ -15,6 +15,17 @@ export const RemoveTheDomainFromUrl = (url: string) => {
|
|||||||
return modifiedUrl;
|
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) =>
|
export const ensureStartsWith = (stringToCheck: string, startsWith: string) =>
|
||||||
stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;
|
stringToCheck.startsWith(startsWith) ? stringToCheck : `${startsWith}${stringToCheck}`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user