From 1afc15f6121b09523ca4cb22a9dc0c63816fe61e Mon Sep 17 00:00:00 2001 From: Flor Date: Thu, 21 Nov 2024 11:58:11 -0300 Subject: [PATCH 1/2] fixed title tag too long --- src/components/Seo/Seo.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Seo/Seo.js b/src/components/Seo/Seo.js index f7f3627..0ef3e90 100644 --- a/src/components/Seo/Seo.js +++ b/src/components/Seo/Seo.js @@ -23,7 +23,11 @@ function Seo({ description, lang, meta, title, keywords }) { lang, }} title={title} - titleTemplate={defaultTitle ? `%s | ${defaultTitle}` : null} + titleTemplate={defaultTitle + ? ((title.length + defaultTitle.length) <= 50 + ? `%s | ${defaultTitle}` + : `%s`) + : null} meta={[ { name: `robots`, From dec133a8b984a83e40ce645a166772481508f937 Mon Sep 17 00:00:00 2001 From: Flor Date: Thu, 21 Nov 2024 12:07:47 -0300 Subject: [PATCH 2/2] fixed sonar warning --- src/components/Seo/Seo.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/components/Seo/Seo.js b/src/components/Seo/Seo.js index 0ef3e90..294fa1d 100644 --- a/src/components/Seo/Seo.js +++ b/src/components/Seo/Seo.js @@ -17,17 +17,23 @@ function Seo({ description, lang, meta, title, keywords }) { const preventIndex = robots ? `index, follow` : `noindex, nofollow` const defaultKeywords = keywords || siteKeywords + let titleTemplateValue = null; + + if (defaultTitle) { + if (title.length + defaultTitle.length <= 50) { + titleTemplateValue = `%s | ${defaultTitle}`; // Concatenar si la longitud total es corta + } else { + titleTemplateValue = `%s`; // Usar solo el título particular + } + } + return (