Skip to content

Commit

Permalink
Fix: title template
Browse files Browse the repository at this point in the history
  • Loading branch information
luciobenini committed Jul 11, 2022
1 parent a3e20a4 commit ec65ec9
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@pittica/gatsby-plugin-seo",
"private": false,
"description": "SEO optimization plugin for GatsbyJS.",
"version": "4.3.8",
"version": "4.3.9",
"author": {
"name": "Lucio Benini",
"email": "info@pittica.com",
Expand Down
21 changes: 18 additions & 3 deletions src/components/seo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,13 @@ export default function Seo({
lang: postLocale?.language,
}}
title={postTitle}
titleTemplate={title ? `%s | ${context.title}` : context.title}
titleTemplate={
title != context.title
? postTitle
? `%s | ${context.title}`
: context.title
: null
}
>
{keywords && keywords.length > 0 && (
<meta
Expand All @@ -49,8 +55,17 @@ export default function Seo({
/>
)}
</Helmet>
<PageMeta siteUrl={context.siteUrl} description={postDescription} image={image} />
<Links siteUrl={context.siteUrl} path={path} next={next} previous={previous} />
<PageMeta
siteUrl={context.siteUrl}
description={postDescription}
image={image}
/>
<Links
siteUrl={context.siteUrl}
path={path}
next={next}
previous={previous}
/>
<OpenGraph
url={url}
article={isBlogPost}
Expand Down
4 changes: 3 additions & 1 deletion src/gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,9 @@ export function wrapPageElement(
lang: locale.language,
}}
title={seo.title || title}
titleTemplate={seo.title ? `%s | ${title}` : title}
titleTemplate={
seo.title != title ? (seo.title ? `%s | ${title}` : title) : null
}
>
{facebook.app && (
<meta property="fb:app_id" content={facebook.app} key="fb-app-id" />
Expand Down

0 comments on commit ec65ec9

Please sign in to comment.