From 59243ddeede484eeebe54af3829efeff90820817 Mon Sep 17 00:00:00 2001 From: Gabriel Horacio Cutrini Date: Mon, 7 Apr 2025 22:57:38 -0300 Subject: [PATCH] Makes SummitCard link at card level when link prop actually provided. Signed-off-by: Gabriel Horacio Cutrini --- src/components/LinkComponent.js | 68 +++++++++++++----------- src/components/PastSummits/index.jsx | 2 + src/components/SummitCard/index.jsx | 2 +- src/components/UpcomingSummits/index.jsx | 2 + 4 files changed, 43 insertions(+), 31 deletions(-) diff --git a/src/components/LinkComponent.js b/src/components/LinkComponent.js index 09d06fb04..6b0f59b47 100644 --- a/src/components/LinkComponent.js +++ b/src/components/LinkComponent.js @@ -1,37 +1,45 @@ -import React from 'react' -import PropTypes from "prop-types" -import { Link } from 'gatsby' -import { OutboundLink } from 'gatsby-plugin-google-analytics' +import * as React from "react"; +import PropTypes from "prop-types"; +import { Link } from "gatsby"; +import { OutboundLink } from "gatsby-plugin-google-analytics"; -const LinkComponent = class extends React.Component { - render() { +const LinkComponent = ({ href, children, ...rest }) => { + if (!href) { + // render children directly if no href is provided + return <>{children}; + } - let { href, children, className, id, ...rest } = this.props; + if (/^(http:\/\/|https:\/\/|www\.)/.test(href)) { + return ( + + {children} + + ); + } - if(href.match(/^(http:\/\/|https:\/\/|www\.)/)){ - return ( - - {children} - - ) - } else if (href.match(/mailto:/)){ - return ( - - {children} - - ) - } else { - return ( - - {children} - - ) - } + if (/mailto:/.test(href)) { + return ( + + {children} + + ); } -} + + return ( + + {children} + + ); +}; LinkComponent.propTypes = { - href: PropTypes.string.isRequired -} + href: PropTypes.string, + children: PropTypes.node.isRequired +}; -export default LinkComponent +export default LinkComponent; diff --git a/src/components/PastSummits/index.jsx b/src/components/PastSummits/index.jsx index 9d4cfb64e..f0bf3378f 100644 --- a/src/components/PastSummits/index.jsx +++ b/src/components/PastSummits/index.jsx @@ -10,6 +10,7 @@ const PAST_SUMMITS = [ background: "/img/summit-landing/cards/summit-asia.png", date: "September 3 & 4, 2024", location: "Suwon Convention Center, Suwon, South Korea", + link: "https://youtube.com/playlist?list=PLKqaoAnDyfgqjY-vzt45oayXLa4aLpMRU&feature=shared", notification: { text: " ", button: { @@ -36,6 +37,7 @@ const PastSummits = ({ title }) => { ))} diff --git a/src/components/SummitCard/index.jsx b/src/components/SummitCard/index.jsx index 4e3d8f5a9..8795e6d7a 100644 --- a/src/components/SummitCard/index.jsx +++ b/src/components/SummitCard/index.jsx @@ -11,7 +11,7 @@ const SummitCard = ({ background, summit, cardStyles, - link = "https://summit2025.openinfra.org", + link }) => { if (!summit) return null; diff --git a/src/components/UpcomingSummits/index.jsx b/src/components/UpcomingSummits/index.jsx index 5ab61ed33..91a821bb6 100644 --- a/src/components/UpcomingSummits/index.jsx +++ b/src/components/UpcomingSummits/index.jsx @@ -10,6 +10,7 @@ const UPCOMING_SUMMITS = [ background: "/img/summit-landing/cards/summit-europe-25-2.png", date: "October 17-19, 2025", location: "École Polytechnique, Paris-Saclay, France", + link: "https://summit2025.openinfra.org", notification: { text: " ", button: { @@ -36,6 +37,7 @@ const UpcomingSummits = ({ title }) => { ))}