Skip to content

Commit

Permalink
fix: properly include URL parameters and anchors for internal links
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusforsberg committed Jun 4, 2024
1 parent b9fa67a commit 7707a13
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/helpers/generateHref.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import {isCustomLink, isEmailLink, isExternalLink, isInternalLink, isPhoneLink}
export const generateHref = {
internal: (link: LinkValue, hrefResolver?: (link: InternalLink) => string) =>
isInternalLink(link) && link.internalLink
? hrefResolver
? hrefResolver(link)
: `/${link.internalLink.slug?.current?.replace(/^\//, '')}`
? (hrefResolver
? hrefResolver(link)
: `/${link.internalLink.slug?.current?.replace(/^\//, '')}`) +
(link.parameters?.trim() || '') +
(link.anchor?.trim() || '')
: '#',
external: (link: LinkValue) =>
isExternalLink(link) && link.url
Expand Down

0 comments on commit 7707a13

Please sign in to comment.