Skip to content

Commit b1bc5e5

Browse files
Merge pull request #83 from bitlogic/SBIT-463
SBIT-463 - fixed title tag too long
2 parents 6088a57 + dec133a commit b1bc5e5

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/components/Seo/Seo.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,23 @@ function Seo({ description, lang, meta, title, keywords }) {
1717
const preventIndex = robots ? `index, follow` : `noindex, nofollow`
1818
const defaultKeywords = keywords || siteKeywords
1919

20+
let titleTemplateValue = null;
21+
22+
if (defaultTitle) {
23+
if (title.length + defaultTitle.length <= 50) {
24+
titleTemplateValue = `%s | ${defaultTitle}`; // Concatenar si la longitud total es corta
25+
} else {
26+
titleTemplateValue = `%s`; // Usar solo el título particular
27+
}
28+
}
29+
2030
return (
2131
<Helmet
2232
htmlAttributes={{
2333
lang,
2434
}}
2535
title={title}
26-
titleTemplate={defaultTitle ? `%s | ${defaultTitle}` : null}
36+
titleTemplate={titleTemplateValue}
2737
meta={[
2838
{
2939
name: `robots`,

0 commit comments

Comments
 (0)