Skip to content

Commit ee12619

Browse files
committed
Link and withBasePath
1 parent 44f03d5 commit ee12619

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

src/app/resources/guides/page.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
import ContentSplitSection from '@/components/ContentSplitSection';
33
import Image from 'next/image';
44
import SharedContent from './SharedContent.mdx'
5-
5+
import { withBasePath } from '@/lib/utils';
66

77
<ContentSplitSection
88
title="Elevate Your Project"
99
subtitle="Our template helps you reach new heights with innovative solutions"
1010
media={
1111
<Image
12-
src="/logo.png"
12+
src={withBasePath("/logo.png")}
1313
alt="A futuristic concept"
1414
width={100}
1515
height={100}

src/components/DesktopMenu.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ type NavigationProps = {
2727
}
2828

2929
const ListItem = React.forwardRef<
30-
React.ElementRef<"a">,
31-
React.ComponentPropsWithoutRef<"a">
30+
React.ElementRef<typeof Link>,
31+
React.ComponentPropsWithoutRef<typeof Link> & { title: string }
3232
>(({ className, title, children, ...props }, ref) => {
3333
return (
3434
<li>
3535
<NavigationMenuLink asChild>
36-
<a
36+
<Link
3737
ref={ref}
3838
className={cn(
3939
"block select-none rounded-md p-3 leading-none no-underline outline-none transition-colors hover:bg-accent hover:text-accent-foreground focus:bg-accent focus:text-accent-foreground",
@@ -47,12 +47,12 @@ const ListItem = React.forwardRef<
4747
{children}
4848
</p>
4949
)}
50-
</a>
50+
</Link>
5151
</NavigationMenuLink>
5252
</li>
53-
)
54-
})
55-
ListItem.displayName = "ListItem"
53+
);
54+
});
55+
ListItem.displayName = "ListItem";
5656

5757
const DesktopMenu = ({ items }: NavigationProps) => {
5858
return (

src/components/Funding.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import React from 'react';
22
import Image from 'next/image';
33
import { FundingProps, LogoItem } from './FooterTypes';
4+
import { withBasePath } from '@/lib/utils';
5+
46

57
const Logo = ({ logo }: { logo: LogoItem }) => {
68
const image = (
79
<Image
8-
src={logo.src}
10+
src={withBasePath(logo.src)}
911
alt={logo.alt}
1012
width={logo.width}
1113
height={logo.height}

src/components/Logo.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react';
22
import Image from 'next/image';
33
import Link from 'next/link';
4+
import { withBasePath } from '@/lib/utils';
45

56
interface LogoProps {
67
icon?: string;
@@ -11,7 +12,7 @@ const LogoProject = ({ icon = '', title = '' }: LogoProps) => {
1112
return (
1213
<div className="flex-shrink-0 flex items-center mr-4">
1314
<Link href="/">
14-
<Image src={icon} alt={title} width={32} height={32} className="mr-4"/>
15+
<Image src={withBasePath(icon)} alt={title} width={32} height={32} className="mr-4"/>
1516
</Link>
1617
<Link href="/" className="font-bold text-[var(--link-color)] hover:text-[var(--link-hover)]">
1718
{title}

src/lib/utils.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,9 @@ import { twMerge } from "tailwind-merge"
44
export function cn(...inputs: ClassValue[]) {
55
return twMerge(clsx(inputs))
66
}
7+
8+
9+
export const withBasePath = (path: string) => {
10+
const basePath = process.env.NODE_ENV === 'production' ? '/next-project-site' : ''
11+
return `${ basePath || ''}${path}`;
12+
};

0 commit comments

Comments
 (0)