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"
4040import ProductList from "../components/ProductList"
4141import PageHero from "../components/PageHero"
4242import FeedbackCard from "../components/FeedbackCard"
43+ import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
4344
4445import { getImage , getSrc } from "../utils/image"
4546import { trackCustomEvent } from "../utils/matomo"
@@ -1263,9 +1264,9 @@ const DappsPage = ({
12631264 </ StyledH2 >
12641265 < Text >
12651266 < Translation id = "page-dapps-get-started-subtitle" /> { " " }
1266- < InlineLink to = "/glossary/# transaction-fee">
1267+ < GlossaryTooltip termKey = " transaction-fee">
12671268 < Translation id = "transaction-fees" />
1268- </ InlineLink >
1269+ </ GlossaryTooltip >
12691270 </ Text >
12701271 < Row >
12711272 < StepBoxContainer >
Original file line number Diff line number Diff line change @@ -30,7 +30,6 @@ import CrowdinContributors from "../components/FileContributorsCrowdin"
3030import GitHubContributors from "../components/FileContributorsGitHub"
3131import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
3232import InfoBanner from "../components/InfoBanner"
33- import InlineLink from "../components/Link"
3433import { mdxTableComponents } from "../components/Table"
3534import PageMetadata from "../components/PageMetadata"
3635import TableOfContents , {
@@ -43,6 +42,7 @@ import DocsNav from "../components/DocsNav"
4342import DeveloperDocsLinks from "../components/DeveloperDocsLinks"
4443import RollupProductDevDoc from "../components/RollupProductDevDoc"
4544import YouTube from "../components/YouTube"
45+ import MdLink from "../components/MdLink"
4646
4747import { isLangRightToLeft } from "../utils/translations"
4848import { Lang } from "../utils/languages"
@@ -193,7 +193,7 @@ const BackToTop = (props: ChildOnlyProp) => (
193193// Note: you must pass components to MDXProvider in order to render them in markdown files
194194// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
195195const components = {
196- a : InlineLink ,
196+ a : MdLink ,
197197 h1 : H1 ,
198198 h2 : H2 ,
199199 h3 : H3 ,
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ import DocLink from "../components/DocLink"
2626import Contributors from "../components/Contributors"
2727import InfoBanner from "../components/InfoBanner"
2828import UpgradeStatus from "../components/UpgradeStatus"
29- import InlineLink from "../components/Link"
3029import { mdxTableComponents } from "../components/Table"
3130import Logo from "../components/Logo"
3231import MeetupList from "../components/MeetupList"
@@ -45,6 +44,7 @@ import Breadcrumbs from "../components/Breadcrumbs"
4544import RoadmapActionCard from "../components/Roadmap/RoadmapActionCard"
4645import RoadmapImageContent from "../components/Roadmap/RoadmapImageContent"
4746import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
47+ import MdLink from "../components/MdLink"
4848import {
4949 Page ,
5050 InfoColumn ,
@@ -118,7 +118,7 @@ const TitleCard = (props: ChildOnlyProp) => (
118118// Note: you must pass components to MDXProvider in order to render them in markdown files
119119// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
120120const components = {
121- a : InlineLink ,
121+ a : MdLink ,
122122 h1 : H1 ,
123123 h2 : H2 ,
124124 h3 : H3 ,
Original file line number Diff line number Diff line change @@ -27,7 +27,6 @@ import DocLink from "../components/DocLink"
2727import Contributors from "../components/Contributors"
2828import InfoBanner from "../components/InfoBanner"
2929import UpgradeStatus from "../components/UpgradeStatus"
30- import InlineLink from "../components/Link"
3130import { mdxTableComponents } from "../components/Table"
3231import Logo from "../components/Logo"
3332import MeetupList from "../components/MeetupList"
@@ -54,6 +53,7 @@ import WithdrawalCredentials from "../components/Staking/WithdrawalCredentials"
5453import WithdrawalsTabComparison from "../components/Staking/WithdrawalsTabComparison"
5554import Callout from "../components/Callout"
5655import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
56+ import MdLink from "../components/MdLink"
5757
5858import { isLangRightToLeft , TranslationKey } from "../utils/translations"
5959import { Lang } from "../utils/languages"
@@ -287,7 +287,7 @@ const TableContainer = (props: BoxProps) => (
287287// Note: you must pass components to MDXProvider in order to render them in markdown files
288288// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
289289const components = {
290- a : InlineLink ,
290+ a : MdLink ,
291291 h1 : Header1 ,
292292 h2 : H2 ,
293293 h3 : H3 ,
Original file line number Diff line number Diff line change @@ -47,6 +47,7 @@ import QuizWidget from "../components/Quiz/QuizWidget"
4747import { Item as ItemTableOfContents } from "../components/TableOfContents/utils"
4848import GlossaryDefinition from "../components/Glossary/GlossaryDefinition"
4949import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
50+ import MdLink from "../components/MdLink"
5051
5152import { getLocaleTimestamp } from "../utils/time"
5253import { isLangRightToLeft , TranslationKey } from "../utils/translations"
@@ -171,7 +172,7 @@ const CardContainer = (props: ChildOnlyProp) => (
171172// Note: you must pass components to MDXProvider in order to render them in markdown files
172173// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
173174const components = {
174- a : InlineLink ,
175+ a : MdLink ,
175176 h1 : Header1 ,
176177 h2 : Header2 ,
177178 h3 : Header3 ,
Original file line number Diff line number Diff line change @@ -20,10 +20,8 @@ import ButtonLink from "../components/ButtonLink"
2020import Card from "../components/Card"
2121import Codeblock from "../components/Codeblock"
2222import TutorialMetadata from "../components/TutorialMetadata"
23- import FileContributors from "../components/FileContributors"
2423import InfoBanner from "../components/InfoBanner"
2524import EnvWarningBanner from "../components/EnvWarningBanner"
26- import InlineLink from "../components/Link"
2725import { mdxTableComponents } from "../components/Table"
2826import PageMetadata from "../components/PageMetadata"
2927import TableOfContents , {
@@ -36,6 +34,7 @@ import YouTube from "../components/YouTube"
3634import PostMergeBanner from "../components/Banners/PostMergeBanner"
3735import FeedbackCard from "../components/FeedbackCard"
3836import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
37+ import MdLink from "../components/MdLink"
3938
4039import { isLangRightToLeft , TranslationKey } from "../utils/translations"
4140import { Lang } from "../utils/languages"
@@ -198,7 +197,7 @@ const KBD = (props) => {
198197// Note: you must pass components to MDXProvider in order to render them in markdown files
199198// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
200199const components = {
201- a : InlineLink ,
200+ a : MdLink ,
202201 h1 : H1 ,
203202 h2 : H2 ,
204203 h3 : H3 ,
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ import Card from "../components/Card"
3131import Contributors from "../components/Contributors"
3232import InfoBanner from "../components/InfoBanner"
3333import UpgradeStatus from "../components/UpgradeStatus"
34- import InlineLink , { BaseLink } from "../components/Link"
34+ import { BaseLink } from "../components/Link"
3535import { mdxTableComponents } from "../components/Table"
3636import BeaconChainActions from "../components/BeaconChainActions"
3737import ShardChainsList from "../components/ShardChainsList"
@@ -51,6 +51,7 @@ import MergeInfographic from "../components/MergeInfographic"
5151import FeedbackCard from "../components/FeedbackCard"
5252import QuizWidget from "../components/Quiz/QuizWidget"
5353import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
54+ import MdLink from "../components/MdLink"
5455import {
5556 MobileButton ,
5657 MobileButtonDropdown ,
@@ -208,7 +209,7 @@ const P = (props: TextProps) => (
208209// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
209210
210211const components = {
211- a : InlineLink ,
212+ a : MdLink ,
212213 h1 : MDXH1 ,
213214 h2 : H2 ,
214215 h3 : H3 ,
Original file line number Diff line number Diff line change @@ -52,6 +52,7 @@ import YouTube from "../components/YouTube"
5252import FeedbackCard from "../components/FeedbackCard"
5353import QuizWidget from "../components/Quiz/QuizWidget"
5454import GlossaryTooltip from "../components/Glossary/GlossaryTooltip"
55+ import MdLink from "../components/MdLink"
5556
5657import { isLangRightToLeft } from "../utils/translations"
5758import { getSummaryPoints } from "../utils/getSummaryPoints"
@@ -109,7 +110,7 @@ export const Paragraph = (props: ChildOnlyProp) => (
109110// Note: you must pass components to MDXProvider in order to render them in markdown files
110111// https://www.gatsbyjs.com/plugins/gatsby-plugin-mdx/#mdxprovider
111112const components = {
112- a : InlineLink ,
113+ a : MdLink ,
113114 h1 : H1 ,
114115 h2 : H2 ,
115116 h3 : H3 ,
You can’t perform that action at this time.
0 commit comments