diff --git a/src/components/Footer/Subscription/subscription.js b/src/components/Footer/Subscription/subscription.js index 6305d1af..d23e78d5 100644 --- a/src/components/Footer/Subscription/subscription.js +++ b/src/components/Footer/Subscription/subscription.js @@ -1,15 +1,41 @@ import { Link } from "gatsby" +import PropTypes from "prop-types" import React from "react" -import { useFooter } from "../../../hooks" +import { useFooter, useLandingUrl } from "../../../hooks" import "./subscription.scss" +const SubscriptionLink = ({ children, subscriptionUrl, landing }) => { + const isExternalLink = subscriptionUrl?.startsWith('http') + + if (landing) { + return {children} + } else if (isExternalLink) { + return ( + + {children} + + ) + } else { + return {children} + } +} + +SubscriptionLink.propTypes = { + children: PropTypes.node.isRequired, + subscriptionUrl: PropTypes.string, + landing: PropTypes.string, +} + export default function Subscription() { const data = useFooter() + const getUrl = useLandingUrl() + const dataSubscription = data?.allStrapiLayout?.nodes[0]?.footer?.subscription + const subscriptionUrl = dataSubscription?.url - const subscriptionLanding = dataSubscription?.landing_page?.slug + const landing = getUrl(dataSubscription?.landing_page?.slug) - const isExternalLink = subscriptionUrl?.startsWith('http') + if (!dataSubscription?.landing_page && !subscriptionUrl) return null return (
@@ -17,27 +43,17 @@ export default function Subscription() {
) -} \ No newline at end of file +} diff --git a/src/hooks/useFooter.js b/src/hooks/useFooter.js index 49a5d00b..b8097518 100644 --- a/src/hooks/useFooter.js +++ b/src/hooks/useFooter.js @@ -92,6 +92,7 @@ const useFooter = () => { subscription { title url + callToAction landing_page { slug } diff --git a/src/schema/layoutSchema.js b/src/schema/layoutSchema.js index 1f8f85b9..8fb0ef12 100644 --- a/src/schema/layoutSchema.js +++ b/src/schema/layoutSchema.js @@ -118,6 +118,7 @@ type StrapiLayoutNavbarNavButtonLanding_page { id: Int title: String url: String + callToAction: String landing_page: StrapiLayoutFooterSubscriptionLanding }