From b0f4479a65585a82871258116991f252856f35ec Mon Sep 17 00:00:00 2001 From: Luca Burgio Date: Tue, 20 Feb 2024 11:07:31 +0100 Subject: [PATCH] fix: logic for canonical --- iconoir.com/components/Header.tsx | 5 ++--- iconoir.com/components/SEO.tsx | 7 ++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/iconoir.com/components/Header.tsx b/iconoir.com/components/Header.tsx index b67036e60..ceb02078a 100644 --- a/iconoir.com/components/Header.tsx +++ b/iconoir.com/components/Header.tsx @@ -26,7 +26,6 @@ export function Header({ currentVersion }: HeaderProps) { 'https://lucaburgio.com/join?utm_source=iconoir&utm_medium=join-head-banner' } target={'_blank'} - rel={'noreferrer'} > Access to the latest updates on new icons and ideas. Join the newsletter. @@ -53,7 +52,7 @@ export function Header({ currentVersion }: HeaderProps) { Donate — Our Mission - + Share with on{' '} X (Twitter) @@ -62,7 +61,7 @@ export function Header({ currentVersion }: HeaderProps) { - + Share with on{' '} X (Twitter) diff --git a/iconoir.com/components/SEO.tsx b/iconoir.com/components/SEO.tsx index e57a600ce..46566c4a4 100644 --- a/iconoir.com/components/SEO.tsx +++ b/iconoir.com/components/SEO.tsx @@ -1,4 +1,5 @@ import Head from 'next/head'; +import { useRouter } from 'next/router'; const TITLE_SUFFIX = 'Iconoir | Free Icons'; @@ -7,13 +8,17 @@ export interface SEOProps { description?: string; } export function SEO({ title, description }: SEOProps) { + const { asPath } = useRouter(); const pageTitle = title ? `${title} | ${TITLE_SUFFIX}` : TITLE_SUFFIX; const pageDescription = description; + const pathWithoutQuery = asPath.split(/[?#]/)[0]; + const canonicalUrl = `https://iconoir.com${pathWithoutQuery !== '/' ? pathWithoutQuery : ''}`; + return ( {pageTitle} - +