Skip to content

Commit 491626a

Browse files
authored
fix(): Optional next link config via props. (#31)
* fix(): Optional next link config via props. * Allow prop passing of custom component.
1 parent de8e3c3 commit 491626a

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/custom/docs/components/triplecard/index.tsx

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Card, CardTitle, CardSubtitle } from './Card'
22
import NextImage from 'next/image'
3+
import NextLink from 'next/link'
34
import { z } from 'zod'
45
import { ComponentProps } from 'react'
56

@@ -20,9 +21,9 @@ const cardSchema = z.array(
2021
}))
2122

2223

23-
const regularLink = (props: ComponentProps<'a'>) => <a {...props}></a>
24-
25-
export const TripleCard = (props: {cards: z.infer<typeof cardSchema>, imageComponent: typeof NextImage | typeof regularLink }) => {
24+
const RegularLink = (props: ComponentProps<'a'>) => <a {...props}></a>
25+
const RegularImage = (props: ComponentProps<'img'>) => <img {...props}></img>
26+
export const TripleCard = (props: {cards: z.infer<typeof cardSchema>, imageComponent: typeof NextImage | typeof RegularImage, linkComponent: typeof NextLink | typeof RegularLink }) => {
2627

2728
return (
2829
<section className="shadow-lg rounded-xl grid grid-cols-1 items-stretch md:grid-cols-3 ">
@@ -65,12 +66,12 @@ export const TripleCard = (props: {cards: z.infer<typeof cardSchema>, imageCompo
6566
return (
6667
<li key={link.title}>
6768

68-
<a
69+
<props.linkComponent
6970
className="font-semibold tracking-tight text-blue-600 dark:text-blue-300"
7071
href={link.link}
7172
>
7273
{link.title}
73-
</a>
74+
</props.linkComponent>
7475
<div className="my-2"></div>
7576
<div className="text-muted-foreground text-xs leading-4">
7677
{link.description}

stories/custom/docs-tripleCard.stories.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ import { DocsTripleCard } from "src";
6565

6666

6767
export function DocsTripleCardDemo() {
68-
return <DocsTripleCard cards={tripleCardProps} imageComponent={(props: ComponentProps<'a'>) => <a {...props}></a>} />;
68+
return <DocsTripleCard cards={tripleCardProps} linkComponent={(props: ComponentProps<'a'>) => <a {...props}></a>} imageComponent={(props: ComponentProps<'img'>) => <img {...props}></img>} />;
6969
}
7070

7171
const meta: Meta<typeof DocsTripleCardDemo> = {

0 commit comments

Comments
 (0)