Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support link text #95

Merged
merged 12 commits into from
Sep 27, 2024
215 changes: 26 additions & 189 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
"negotiator": "^0.6.3"
},
"devDependencies": {
"@prismicio/client": "^7.2.0",
"@prismicio/mock": "^0.3.1",
"@prismicio/client": "7.9.0-alpha.2",
"@prismicio/mock": "0.3.8-alpha.0",
"@size-limit/preset-small-lib": "^9.0.0",
"@types/negotiator": "^0.6.3",
"@types/react-test-renderer": "^18.0.2",
Expand Down Expand Up @@ -99,5 +99,9 @@
},
"publishConfig": {
"access": "public"
},
"overrides": {
"@prismicio/client": "7.9.0-alpha.2",
"@prismicio/mock": "0.3.8-alpha.0"
}
}
13 changes: 11 additions & 2 deletions src/PrismicNextLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const PrismicNextLink = React.forwardRef<
HTMLAnchorElement,
PrismicNextLinkProps
>(function PrismicNextLink(
{ field, document, linkResolver, ...restProps },
{ field, document, linkResolver, children, ...restProps },
ref,
): JSX.Element | null {
const {
Expand All @@ -51,5 +51,14 @@ export const PrismicNextLink = React.forwardRef<
rel = restProps.rel;
}

return <Link ref={ref} {...attrs} {...restProps} href={href} rel={rel} />;
let text: string | undefined;
if (field && "text" in field) {
text = field.text;
}
angeloashmore marked this conversation as resolved.
Show resolved Hide resolved

return (
<Link ref={ref} {...attrs} {...restProps} href={href} rel={rel}>
{children || text}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replied there 🙂

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Once we resolve the conversation there, I will approve this PR. 🙂

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done 👍

</Link>
);
});
Loading
Loading