diff --git a/components/tools/UtmBuilder.tsx b/components/tools/UtmBuilder.tsx index ea13381..37c3710 100644 --- a/components/tools/UtmBuilder.tsx +++ b/components/tools/UtmBuilder.tsx @@ -86,6 +86,32 @@ export default function UtmBuilder({ initialSiteId }: UtmBuilderProps) { setValues({ ...values, [e.target.name]: e.target.value }) } + // Helper to handle path changes when a site is selected + const handlePathChange = (e: React.ChangeEvent) => { + const site = sites.find(s => s.id === selectedSiteId) + if (!site) return + + const path = e.target.value + // Ensure path starts with / if not empty + const safePath = path.startsWith('/') || path === '' ? path : `/${path}` + setValues(v => ({ ...v, url: `https://${site.domain}${safePath}` })) + } + + // Extract path from current URL if site is selected + const getCurrentPath = () => { + const site = sites.find(s => s.id === selectedSiteId) + if (!site || !values.url) return '' + + try { + const urlObj = new URL(values.url) + return urlObj.pathname === '/' ? '' : urlObj.pathname + } catch { + return '' + } + } + + const selectedSite = sites.find(s => s.id === selectedSiteId) + return (
@@ -107,13 +133,28 @@ export default function UtmBuilder({ initialSiteId }: UtmBuilderProps) {
- + {selectedSite ? ( +
+ + https://{selectedSite.domain} + + +
+ ) : ( + + )}

You can add specific paths (e.g., /blog/post-1) to the URL above.