File tree Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Expand file tree Collapse file tree 3 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import { Lang } from "../utils/languages"
17
17
import { trackCustomEvent , MatomoEventOptions } from "../utils/matomo"
18
18
import * as url from "../utils/url"
19
19
import { Direction } from "../types"
20
+ import { SITE_URL , DISCORD_PATH } from "../constants"
20
21
21
22
export interface IBaseProps {
22
23
to ?: string
@@ -63,8 +64,10 @@ const Link: React.FC<IProps> = ({
63
64
64
65
// TODO: in the next PR we are going to deprecate the `to` prop and just use `href`
65
66
// this is to support the ButtonLink component which uses the `to` prop
66
- const to = ( toProp ?? href ) !
67
+ let to = ( toProp ?? href ) !
67
68
69
+ const isDiscordInvite = url . isDiscordInvite ( to )
70
+ if ( isDiscordInvite ) to = new URL ( DISCORD_PATH , SITE_URL ) . href
68
71
const isExternal = url . isExternal ( to )
69
72
const isHash = url . isHash ( to )
70
73
const isGlossary = url . isGlossary ( to )
Original file line number Diff line number Diff line change
1
+ export const SITE_URL = "https://ethereum.org" as const
2
+ export const DISCORD_PATH = "/discord/" as const
1
3
export const GATSBY_FUNCTIONS_PATH = process . env . GATSBY_FUNCTIONS_PATH || "/api"
2
4
3
5
// Quiz Hub
Original file line number Diff line number Diff line change
1
+ import { DISCORD_PATH } from "../constants"
2
+
1
3
const HASH_PATTERN = / ^ # .* /
2
4
const isHashLink = ( href : string ) : boolean => HASH_PATTERN . test ( href )
3
5
6
+ export const isDiscordInvite = ( href : string ) : boolean =>
7
+ href . includes ( DISCORD_PATH ) && ! href . includes ( "http" )
8
+
4
9
export const isExternal = ( href : string ) : boolean =>
5
10
href . includes ( "http" ) || href . includes ( "mailto:" ) || href . includes ( "ipfs" )
6
11
You can’t perform that action at this time.
0 commit comments