diff --git a/next-sitemap.config.js b/next-sitemap.config.js index 171800da..2294842c 100644 --- a/next-sitemap.config.js +++ b/next-sitemap.config.js @@ -1,4 +1,13 @@ module.exports = { siteUrl: process.env.NEXT_PUBLIC_DEFAULT_SITE_URL || 'http://localhost:3000', generateRobotsTxt: true, + exclude: ['/redirect', '/redirect/*'], + robotsTxtOptions: { + policies: [ + { + userAgent: '*', + disallow: ['/redirect', '/redirect/*'], + }, + ], + }, }; diff --git a/src/app/(website)/layout.tsx b/src/app/(website)/layout.tsx index 5a36075a..2932785f 100644 --- a/src/app/(website)/layout.tsx +++ b/src/app/(website)/layout.tsx @@ -74,6 +74,12 @@ async function RootLayout({ children }: { children: React.ReactNode }) { document.head.appendChild(script); } + function loadHandleInitialPageUrl() { + if (!localStorage.getItem('initialPageUrl')) { + localStorage.setItem('initialPageUrl', window.location.href); + } + } + void 0 === window._axcb && (window._axcb = []); window._axcb.push(function (axeptio) { axeptio.on("ready", function() { @@ -89,6 +95,9 @@ async function RootLayout({ children }: { children: React.ReactNode }) { if (choices.clearbit) { loadClearbit(); } + if (choices.initialPageUrl) { + loadHandleInitialPageUrl(); + } }); }); `} diff --git a/src/app/(website)/redirect/page.tsx b/src/app/(website)/redirect/page.tsx new file mode 100644 index 00000000..7577917f --- /dev/null +++ b/src/app/(website)/redirect/page.tsx @@ -0,0 +1,35 @@ +'use client'; + +import { useRouter, useSearchParams } from 'next/navigation'; + +import { Suspense, useEffect } from 'react'; + +import LoadingIcon from '@/svgs/icons/loading.inline.svg'; + +function RedirectComponent() { + const router = useRouter(); + const searchParams = useSearchParams(); + const url = searchParams.get('url'); + + useEffect(() => { + if (url) { + router.push(url); + } + }, [url, router]); + + return ( +
+ +
+ ); +} + +function Redirect() { + return ( + + + + ); +} + +export default Redirect; diff --git a/src/components/pages/home/hero/hero.tsx b/src/components/pages/home/hero/hero.tsx index fc1d5c89..03fa14c6 100644 --- a/src/components/pages/home/hero/hero.tsx +++ b/src/components/pages/home/hero/hero.tsx @@ -35,7 +35,7 @@ function Hero() {
+ ); diff --git a/src/components/shared/calendar/calendar.tsx b/src/components/shared/calendar/calendar.tsx index 4b1223c7..4143db52 100644 --- a/src/components/shared/calendar/calendar.tsx +++ b/src/components/shared/calendar/calendar.tsx @@ -1,12 +1,44 @@ 'use client'; +import { useEffect, useState } from 'react'; + +import type { PrefillAndIframeAttrsConfig } from '@calcom/embed-core'; import Cal from '@calcom/embed-react'; +/* eslint-disable */ function Calendar({ calLink }: { calLink: string }) { + // TODO: in case of more tasks with getting utm from url, move the logic into hooks + const [analyticsData, setAnalyticsData] = useState({ + initialPagePath: '', + 'utm-campaign': '', + 'utm-medium': '', + 'utm-source': '', + 'utm-content': '', + 'utm-term': '', + }); + + useEffect(() => { + const initialPageUrl = localStorage.getItem('initialPageUrl'); + if (initialPageUrl) { + const url = new URL(initialPageUrl); + const urlParams = new URLSearchParams(url.search); + + setAnalyticsData((prev) => ({ + ...prev, + initialPagePath: url.pathname, + 'utm-campaign': urlParams.get('utm_campaign') || '', + 'utm-medium': urlParams.get('utm_medium') || '', + 'utm-source': urlParams.get('utm_source') || '', + 'utm-content': urlParams.get('utm_content') || '', + 'utm-term': urlParams.get('utm_term') || '', + })); + } + }, []); + return (
- +
);