Skip to content

Commit

Permalink
Fix type issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jonaschlegel committed Oct 1, 2024
1 parent 30a0717 commit de7b7e4
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
12 changes: 10 additions & 2 deletions app/components/SocialItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@ import type { FC } from 'react';
import type { SocialType } from '../../types/global';

const SocialItem: FC<SocialType> = ({ Icon, href }) => {
return (
<Link href={href} target="_blank">
const isExternal = typeof href === 'string';

return isExternal ? (
<a href={href} target="_blank" rel="noopener noreferrer">
<span className="inline-block rounded-full border p-2">
<Icon />
</span>
</a>
) : (
<Link href={href}>
<span className="inline-block rounded-full border p-2">
<Icon />
</span>
Expand Down
14 changes: 12 additions & 2 deletions app/projects/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ import type { ProjectType } from '../../../types/global';
import { projectsData } from '../../data/content';

interface ProjectPageProps {
params: { slug: string };
params: Promise<{ slug: string }>;
}

export function generateStaticParams(): Array<{ slug: string }> {
return projectsData.projectsList.map((project) => ({
slug: project.slug,
}));
}

export default async function ProjectPage({ params }: ProjectPageProps) {
const resolvedParams = await params;
const project: ProjectType | undefined = projectsData.projectsList.find(
(proj) => proj.slug === params.slug,
(proj) => proj.slug === resolvedParams.slug,
);

if (!project) {
notFound();
return null;
}

const MDXContent = (
(await import(`../../data/projects/${project.slug}.mdx`)) as {
default: (props: {
Expand All @@ -32,6 +41,7 @@ export default async function ProjectPage({ params }: ProjectPageProps) {
src={project.image}
alt={project.name}
width={2000}
height={1000}
className="object-cover"
/>
</div>
Expand Down
4 changes: 2 additions & 2 deletions types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UrlObject } from 'node:url';
import { UrlObject } from 'node:url';
import type { StaticImageData } from 'next/image';
import type { JSX } from 'react';

Expand Down Expand Up @@ -39,7 +39,7 @@ type StatType = {

type SocialType = {
Icon: React.ComponentType;
href: UrlObject;
href: string | UrlObject;
};

declare module '*.mdx' {
Expand Down

0 comments on commit de7b7e4

Please sign in to comment.