From 130e6a0020c2556dbee88f784d1aa40ee76c9973 Mon Sep 17 00:00:00 2001 From: Xevion Date: Fri, 30 Dec 2022 16:59:12 -0600 Subject: [PATCH] Fix fast refresh by abstracting project/link types into types.ts --- src/components/ItemCard.tsx | 4 ++-- src/pages/index.tsx | 29 +++-------------------------- src/utils/types.ts | 24 ++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 28 deletions(-) create mode 100644 src/utils/types.ts diff --git a/src/components/ItemCard.tsx b/src/components/ItemCard.tsx index ca055ef..aee22cf 100644 --- a/src/components/ItemCard.tsx +++ b/src/components/ItemCard.tsx @@ -5,8 +5,8 @@ import DependentImage from "./DependentImage"; import ReactMarkdown from 'react-markdown' import Link from "next/link"; -import {LinkIcon, LinkIcons} from "../pages"; import {useRouter} from "next/router"; +import {type LinkIcon, LinkIcons} from "../utils/types"; type ItemCardProps = { banner: string; @@ -70,7 +70,7 @@ const ItemCard = ({banner, bannerBlur, title, description, links, location}: Ite {links!.map(({icon, location, newTab}) => e.stopPropagation()}> - {LinkIcons[icon]!({})} + {LinkIcons[icon]?.({})} )} : null} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index ef754b6..8de82c6 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -1,33 +1,10 @@ -import {GetStaticPropsContext, type NextPage} from "next"; +import {type NextPage} from "next"; import Head from "next/head"; import React, {useEffect} from "react"; import ItemCard from "../components/ItemCard"; import {getPlaiceholder} from "plaiceholder"; import {useBreakpointValue} from "../utils/helpers"; -import {IconType} from "react-icons"; -import {AiFillGithub, AiOutlineLink} from "react-icons/ai"; -import {RxOpenInNewWindow} from "react-icons/rx"; - -export type Project = { - title: string; - banner: string; - longDescription: string; - shortDescription: string; - links?: LinkIcon[]; - location: string; -} - - -export const LinkIcons: Record = { - github: AiFillGithub, - external: RxOpenInNewWindow, - link: AiOutlineLink -} -export type LinkIcon = { - icon: keyof typeof LinkIcons; - location: string; - newTab?: boolean; -} +import type {Project} from "../utils/types"; type ProjectWithBlur = Project & { bannerBlur: string }; @@ -36,7 +13,7 @@ type HomeStaticProps = { projects: ProjectWithBlur[]; } -export async function getStaticProps(context: GetStaticPropsContext) { +export async function getStaticProps() { const projects: Project[] = [ { title: "Phototag", diff --git a/src/utils/types.ts b/src/utils/types.ts new file mode 100644 index 0000000..02ed642 --- /dev/null +++ b/src/utils/types.ts @@ -0,0 +1,24 @@ +import {IconType} from "react-icons"; +import {AiFillGithub, AiOutlineLink} from "react-icons/ai"; +import {RxOpenInNewWindow} from "react-icons/rx"; + +export type Project = { + title: string; + banner: string; + longDescription: string; + shortDescription: string; + links?: LinkIcon[]; + location: string; +} + + +export const LinkIcons: Record = { + github: AiFillGithub, + external: RxOpenInNewWindow, + link: AiOutlineLink +} +export type LinkIcon = { + icon: keyof typeof LinkIcons; + location: string; + newTab?: boolean; +} \ No newline at end of file