mirror of
https://github.com/Xevion/xevion.dev.git
synced 2025-12-06 11:17:02 -06:00
Fix fast refresh by abstracting project/link types into types.ts
This commit is contained in:
@@ -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}) =>
|
||||
<Link key={location} href={location} target={(newTab ?? true) ? "_blank" : "_self"}
|
||||
onClick={e => e.stopPropagation()}>
|
||||
{LinkIcons[icon]!({})}
|
||||
{LinkIcons[icon]?.({})}
|
||||
</Link>)}
|
||||
</div>
|
||||
</div> : null}
|
||||
|
||||
@@ -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<string, IconType> = {
|
||||
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",
|
||||
|
||||
24
src/utils/types.ts
Normal file
24
src/utils/types.ts
Normal file
@@ -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<string, IconType> = {
|
||||
github: AiFillGithub,
|
||||
external: RxOpenInNewWindow,
|
||||
link: AiOutlineLink
|
||||
}
|
||||
export type LinkIcon = {
|
||||
icon: keyof typeof LinkIcons;
|
||||
location: string;
|
||||
newTab?: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user