Skip to content

Commit 998f7c8

Browse files
update seo.ts to conditionally include meta tags
1 parent a9247db commit 998f7c8

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

  • examples/react/start-basic-netlify/src/utils

examples/react/start-basic-netlify/src/utils/seo.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,19 @@ export const seo = ({
1111
}) => {
1212
const tags = [
1313
{ title },
14-
{ name: 'description', content: description },
15-
{ name: 'keywords', content: keywords },
14+
...(description ? [{ name: 'description', content: description }] : []),
15+
...(keywords ? [{ name: 'keywords', content: keywords }] : []),
1616
{ name: 'twitter:title', content: title },
17-
{ name: 'twitter:description', content: description },
17+
...(description
18+
? [{ name: 'twitter:description', content: description }]
19+
: []),
1820
{ name: 'twitter:creator', content: '@tannerlinsley' },
1921
{ name: 'twitter:site', content: '@tannerlinsley' },
2022
{ property: 'og:type', content: 'website' },
2123
{ property: 'og:title', content: title },
22-
{ property: 'og:description', content: description },
24+
...(description
25+
? [{ property: 'og:description', content: description }]
26+
: []),
2327
...(image
2428
? [
2529
{ name: 'twitter:image', content: image },

0 commit comments

Comments
 (0)