File tree Expand file tree Collapse file tree 9 files changed +54
-15
lines changed Expand file tree Collapse file tree 9 files changed +54
-15
lines changed Original file line number Diff line number Diff line change
1
+ import React , { ReactNode } from "react"
2
+
3
+ import GlossaryTooltip from "./Glossary/GlossaryTooltip"
4
+ import InlineLink from "./Link"
5
+
6
+ interface Props {
7
+ href : string
8
+ children : ReactNode
9
+ }
10
+
11
+ /**
12
+ * Link component to use in markdown templates.
13
+ *
14
+ * In case the `href` for the given link points to the glossary page, it
15
+ * displays the GlossaryTooltip component instead of a Link.
16
+ *
17
+ * NOTE: This component exists because we want to keep using the link syntax
18
+ * inside of our MD files. The native link syntax has a better UX with Crowdin
19
+ * translations.
20
+ */
21
+ function MdLink ( props : Props ) {
22
+ const regex = new RegExp ( / \/ g l o s s a r y \/ # ( .+ ) / )
23
+ const matches = props . href . match ( regex )
24
+
25
+ // get the `termKey` from the `href`
26
+ // e.g. in `/glossary/#new-term` => "new-term" is the `termKey`
27
+ if ( matches ?. length ) {
28
+ const termKey = matches [ 1 ]
29
+
30
+ return < GlossaryTooltip termKey = { termKey } children = { props . children } />
31
+ }
32
+
33
+ return < InlineLink { ...props } />
34
+ }
35
+
36
+ export default MdLink
Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ import PageMetadata from "../components/PageMetadata"
40
40
import ProductList from "../components/ProductList"
41
41
import PageHero from "../components/PageHero"
42
42
import FeedbackCard from "../components/FeedbackCard"
43
+ import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
43
44
44
45
import { getImage , getSrc } from "../utils/image"
45
46
import { trackCustomEvent } from "../utils/matomo"
@@ -1263,9 +1264,9 @@ const DappsPage = ({
1263
1264
</ StyledH2 >
1264
1265
< Text >
1265
1266
< Translation id = "page-dapps-get-started-subtitle" /> { " " }
1266
- < InlineLink to = "/glossary/# transaction-fee">
1267
+ < GlossaryTooltip termKey = " transaction-fee">
1267
1268
< Translation id = "transaction-fees" />
1268
- </ InlineLink >
1269
+ </ GlossaryTooltip >
1269
1270
</ Text >
1270
1271
< Row >
1271
1272
< StepBoxContainer >
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ import CrowdinContributors from "../components/FileContributorsCrowdin"
30
30
import GitHubContributors from "../components/FileContributorsGitHub"
31
31
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
32
32
import InfoBanner from "../components/InfoBanner"
33
- import InlineLink from "../components/Link"
34
33
import { mdxTableComponents } from "../components/Table"
35
34
import PageMetadata from "../components/PageMetadata"
36
35
import TableOfContents , {
@@ -43,6 +42,7 @@ import DocsNav from "../components/DocsNav"
43
42
import DeveloperDocsLinks from "../components/DeveloperDocsLinks"
44
43
import RollupProductDevDoc from "../components/RollupProductDevDoc"
45
44
import YouTube from "../components/YouTube"
45
+ import MdLink from "../components/MdLink"
46
46
47
47
import { isLangRightToLeft } from "../utils/translations"
48
48
import { Lang } from "../utils/languages"
@@ -193,7 +193,7 @@ const BackToTop = (props: ChildOnlyProp) => (
193
193
// Note: you must pass components to MDXProvider in order to render them in markdown files
194
194
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
195
195
const components = {
196
- a : InlineLink ,
196
+ a : MdLink ,
197
197
h1 : H1 ,
198
198
h2 : H2 ,
199
199
h3 : H3 ,
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import DocLink from "../components/DocLink"
26
26
import Contributors from "../components/Contributors"
27
27
import InfoBanner from "../components/InfoBanner"
28
28
import UpgradeStatus from "../components/UpgradeStatus"
29
- import InlineLink from "../components/Link"
30
29
import { mdxTableComponents } from "../components/Table"
31
30
import Logo from "../components/Logo"
32
31
import MeetupList from "../components/MeetupList"
@@ -45,6 +44,7 @@ import Breadcrumbs from "../components/Breadcrumbs"
45
44
import RoadmapActionCard from "../components/Roadmap/RoadmapActionCard"
46
45
import RoadmapImageContent from "../components/Roadmap/RoadmapImageContent"
47
46
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
47
+ import MdLink from "../components/MdLink"
48
48
import {
49
49
Page ,
50
50
InfoColumn ,
@@ -118,7 +118,7 @@ const TitleCard = (props: ChildOnlyProp) => (
118
118
// Note: you must pass components to MDXProvider in order to render them in markdown files
119
119
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
120
120
const components = {
121
- a : InlineLink ,
121
+ a : MdLink ,
122
122
h1 : H1 ,
123
123
h2 : H2 ,
124
124
h3 : H3 ,
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ import DocLink from "../components/DocLink"
27
27
import Contributors from "../components/Contributors"
28
28
import InfoBanner from "../components/InfoBanner"
29
29
import UpgradeStatus from "../components/UpgradeStatus"
30
- import InlineLink from "../components/Link"
31
30
import { mdxTableComponents } from "../components/Table"
32
31
import Logo from "../components/Logo"
33
32
import MeetupList from "../components/MeetupList"
@@ -54,6 +53,7 @@ import WithdrawalCredentials from "../components/Staking/WithdrawalCredentials"
54
53
import WithdrawalsTabComparison from "../components/Staking/WithdrawalsTabComparison"
55
54
import Callout from "../components/Callout"
56
55
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
56
+ import MdLink from "../components/MdLink"
57
57
58
58
import { isLangRightToLeft , TranslationKey } from "../utils/translations"
59
59
import { Lang } from "../utils/languages"
@@ -287,7 +287,7 @@ const TableContainer = (props: BoxProps) => (
287
287
// Note: you must pass components to MDXProvider in order to render them in markdown files
288
288
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
289
289
const components = {
290
- a : InlineLink ,
290
+ a : MdLink ,
291
291
h1 : Header1 ,
292
292
h2 : H2 ,
293
293
h3 : H3 ,
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import QuizWidget from "../components/Quiz/QuizWidget"
47
47
import { Item as ItemTableOfContents } from "../components/TableOfContents/utils"
48
48
import GlossaryDefinition from "../components/Glossary/GlossaryDefinition"
49
49
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
50
+ import MdLink from "../components/MdLink"
50
51
51
52
import { getLocaleTimestamp } from "../utils/time"
52
53
import { isLangRightToLeft , TranslationKey } from "../utils/translations"
@@ -171,7 +172,7 @@ const CardContainer = (props: ChildOnlyProp) => (
171
172
// Note: you must pass components to MDXProvider in order to render them in markdown files
172
173
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
173
174
const components = {
174
- a : InlineLink ,
175
+ a : MdLink ,
175
176
h1 : Header1 ,
176
177
h2 : Header2 ,
177
178
h3 : Header3 ,
Original file line number Diff line number Diff line change @@ -20,10 +20,8 @@ import ButtonLink from "../components/ButtonLink"
20
20
import Card from "../components/Card"
21
21
import Codeblock from "../components/Codeblock"
22
22
import TutorialMetadata from "../components/TutorialMetadata"
23
- import FileContributors from "../components/FileContributors"
24
23
import InfoBanner from "../components/InfoBanner"
25
24
import EnvWarningBanner from "../components/EnvWarningBanner"
26
- import InlineLink from "../components/Link"
27
25
import { mdxTableComponents } from "../components/Table"
28
26
import PageMetadata from "../components/PageMetadata"
29
27
import TableOfContents , {
@@ -36,6 +34,7 @@ import YouTube from "../components/YouTube"
36
34
import PostMergeBanner from "../components/Banners/PostMergeBanner"
37
35
import FeedbackCard from "../components/FeedbackCard"
38
36
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
37
+ import MdLink from "../components/MdLink"
39
38
40
39
import { isLangRightToLeft , TranslationKey } from "../utils/translations"
41
40
import { Lang } from "../utils/languages"
@@ -198,7 +197,7 @@ const KBD = (props) => {
198
197
// Note: you must pass components to MDXProvider in order to render them in markdown files
199
198
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
200
199
const components = {
201
- a : InlineLink ,
200
+ a : MdLink ,
202
201
h1 : H1 ,
203
202
h2 : H2 ,
204
203
h3 : H3 ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import Card from "../components/Card"
31
31
import Contributors from "../components/Contributors"
32
32
import InfoBanner from "../components/InfoBanner"
33
33
import UpgradeStatus from "../components/UpgradeStatus"
34
- import InlineLink , { BaseLink } from "../components/Link"
34
+ import { BaseLink } from "../components/Link"
35
35
import { mdxTableComponents } from "../components/Table"
36
36
import BeaconChainActions from "../components/BeaconChainActions"
37
37
import ShardChainsList from "../components/ShardChainsList"
@@ -51,6 +51,7 @@ import MergeInfographic from "../components/MergeInfographic"
51
51
import FeedbackCard from "../components/FeedbackCard"
52
52
import QuizWidget from "../components/Quiz/QuizWidget"
53
53
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
54
+ import MdLink from "../components/MdLink"
54
55
import {
55
56
MobileButton ,
56
57
MobileButtonDropdown ,
@@ -208,7 +209,7 @@ const P = (props: TextProps) => (
208
209
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
209
210
210
211
const components = {
211
- a : InlineLink ,
212
+ a : MdLink ,
212
213
h1 : MDXH1 ,
213
214
h2 : H2 ,
214
215
h3 : H3 ,
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ import YouTube from "../components/YouTube"
52
52
import FeedbackCard from "../components/FeedbackCard"
53
53
import QuizWidget from "../components/Quiz/QuizWidget"
54
54
import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
55
+ import MdLink from "../components/MdLink"
55
56
56
57
import { isLangRightToLeft } from "../utils/translations"
57
58
import { getSummaryPoints } from "../utils/getSummaryPoints"
@@ -109,7 +110,7 @@ export const Paragraph = (props: ChildOnlyProp) => (
109
110
// Note: you must pass components to MDXProvider in order to render them in markdown files
110
111
// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
111
112
const components = {
112
- a : InlineLink ,
113
+ a : MdLink ,
113
114
h1 : H1 ,
114
115
h2 : H2 ,
115
116
h3 : H3 ,
You can’t perform that action at this time.
0 commit comments