Skip to content

Commit bd11b94

Browse files
committed
fix: show article title when present
1 parent 2c76868 commit bd11b94

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/components/atomic/seo.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import Helmet from "react-helmet"
1111
import { useStaticQuery, graphql } from "gatsby"
1212
import { useLocation } from "@reach/router"
1313

14-
function SEO({ description='', lang=`en`, meta=[], title, heading }) {
14+
function SEO({ description = "", lang = `en`, meta = [], title, heading }) {
1515
const location = useLocation()
1616
const pathname = location.pathname
1717
// debugger
@@ -42,14 +42,15 @@ function SEO({ description='', lang=`en`, meta=[], title, heading }) {
4242
}
4343
`)
4444

45+
const title = site.metadata.title || title
4546
const metaDescription =
4647
meta.excerpt || description || site.siteMetadata.description
4748
const author = meta.author || site.siteMetadata.author
4849
const baseURL = site.siteMetadata.base_url
4950

5051
let socialImageURLs = {}
5152

52-
allFile.edges.forEach(edge => {
53+
allFile.edges.forEach((edge) => {
5354
if (edge.node.name === "social-card-blog") {
5455
socialImageURLs["BLOG"] = edge.node.publicURL
5556
} else if (edge.node.name === "social-card") {
@@ -72,14 +73,20 @@ function SEO({ description='', lang=`en`, meta=[], title, heading }) {
7273
<meta property="description" content={metaDescription} />
7374
<meta property="og:title" content={heading} />
7475
<meta property="og:description" content={metaDescription} />
75-
<meta property="og:image" content={`${baseURL}${meta.cover? `${meta.cover}`: socialImageURL}`} />
76+
<meta
77+
property="og:image"
78+
content={`${baseURL}${meta.cover ? `${meta.cover}` : socialImageURL}`}
79+
/>
7680
<meta property="og:type" content={"website"} />
7781
<meta name="twitter:card" content={"summary_large_image"} />
7882
<meta name="twitter:site" content={"@tattlemade"} />
7983
<meta name="twitter:creator" content={"@tattlemade"} />
8084
<meta name="twitter:title" content={heading} />
8185
<meta name="twitter:description" content={metaDescription} />
82-
<meta name="twitter:image" content={`${baseURL}${meta.cover? `${meta.cover}`: socialImageURL}`} />
86+
<meta
87+
name="twitter:image"
88+
content={`${baseURL}${meta.cover ? `${meta.cover}` : socialImageURL}`}
89+
/>
8390
{meta.tags && (
8491
<meta
8592
name="keywords"

0 commit comments

Comments
 (0)