Skip to content

Commit

Permalink
Refactor defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
josephfusco committed Jul 24, 2024
1 parent db3f846 commit d631c5c
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions components/OpenGraph.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,38 @@ import Head from 'next/head'

const OpenGraph = ({ seo } ) => {

const {
metaDesc = '',
opengraphDescription = '',
opengraphImage = null,
opengraphTitle = '',
opengraphType = '',
opengraphUrl = '',
title = '',
twitterDescription = '',
twitterTitle = '',
} = seo
const {
metaDesc = '',
opengraphDescription = '',
opengraphImage = { sourceUrl: '/default-og-image.jpg' },
opengraphTitle = '',
opengraphType = 'website',
opengraphUrl = '',
title = '',
twitterDescription = '',
twitterTitle = '',
} = seo || {}; // Ensure seo is not null or undefined


return (
<>
<Head>
<title>{title}</title>
<meta name="description" content={metaDesc} />
return (
<>
<Head>
<title>{title}</title>
<meta name="description" content={metaDesc} />

<meta property="og:url" content={opengraphUrl} />
<meta property="og:type" content={opengraphType} />
<meta property="og:title" content={opengraphTitle} />
<meta property="og:description" content={opengraphDescription} />
<meta property="og:image" content={opengraphImage?.sourceUrl || '/default-og-image.jpg'} />
<meta property="og:url" content={opengraphUrl} />
<meta property="og:type" content={opengraphType} />
<meta property="og:title" content={opengraphTitle} />
<meta property="og:description" content={opengraphDescription} />
<meta property="og:image" content={opengraphImage?.sourceUrl} />

<meta property="twitter:url" content={opengraphUrl} />
<meta name="twitter:title" content={twitterTitle} />
<meta name="twitter:description" content={twitterDescription} />
<meta name="twitter:image" content={opengraphImage?.sourceUrl || '/default-og-image.jpg'} />

</Head>
</>
)
<meta property="twitter:url" content={opengraphUrl} />
<meta name="twitter:title" content={twitterTitle} />
<meta name="twitter:description" content={twitterDescription} />
<meta name="twitter:image" content={opengraphImage?.sourceUrl} />
</Head>
</>
)
}

OpenGraph.fragments = {
Expand Down

0 comments on commit d631c5c

Please sign in to comment.