Skip to content

Commit

Permalink
internalRouteを使う
Browse files Browse the repository at this point in the history
  • Loading branch information
k35o committed Jul 31, 2024
1 parent e30cbbd commit 4e498ed
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/app/blog/_components/blog-card/blog-card.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Heading } from '@/components/heading';
import { TextTag } from '@/components/text-tag';
import { Route } from 'next';
import { isInternalRoute } from '@/utils/is-internal-route';
import Link from 'next/link';

export const BlogCard = <T extends string>({
export const BlogCard = ({
link,
emotion,
title,
Expand All @@ -14,11 +14,10 @@ export const BlogCard = <T extends string>({
title: string;
tags: [string?, string?, string?, string?, string?];
}) => {
const isExternal = link.startsWith('http');
return (
<section className="h-40 rounded-xl bg-white shadow-md">
{isExternal ? (
<a href={link} target="_blank" rel="noopener noreferrer">
{isInternalRoute(link) ? (
<Link href={link}>
<div className="flex gap-6 p-4">
<div className="flex h-32 w-32 shrink-0 items-center justify-center rounded-lg bg-bgLight text-7xl">
{emotion}
Expand All @@ -39,9 +38,9 @@ export const BlogCard = <T extends string>({
)}
</div>
</div>
</a>
</Link>
) : (
<Link href={link as Route<T>}>
<a href={link} target="_blank" rel="noopener noreferrer">
<div className="flex gap-6 p-4">
<div className="flex h-32 w-32 shrink-0 items-center justify-center rounded-lg bg-bgLight text-7xl">
{emotion}
Expand All @@ -62,7 +61,7 @@ export const BlogCard = <T extends string>({
)}
</div>
</div>
</Link>
</a>
)}
</section>
);
Expand Down

0 comments on commit 4e498ed

Please sign in to comment.