chore: fix SEO tags loading for post pages

This commit is contained in:
Corbin Crutchley
2022-09-25 05:50:57 -07:00
parent 4a5dc25f20
commit cb7903d8a5
5 changed files with 10 additions and 9 deletions

View File

@@ -6,10 +6,10 @@ const { keywords, editedTime, publishedTime, unicornsData } = Astro.props as Pro
const author = unicornsData.map(uni => uni.name).join(",");
---
<>{keywords.map(keyword =>
<meta property="article:tag" content={keyword} />)}
<>{keywords?.length ? keywords.map(keyword =>
<meta property="article:tag" content={keyword} />) : null}
</>
<meta property="article:section" content="Technology" />,
<meta property="article:section" content="Technology" />
<meta property="article:author" content={author}/>
<>{editedTime &&
<meta property="article:modified_time" content={editedTime} />}

View File

@@ -19,7 +19,7 @@ const {langData, siteMetadata, pathName} = Astro.props as Props;
href-lang="x-default"
/>
)}
{langData?.otherLangs &&
{langData?.otherLangs?.length ?
langData.otherLangs.map((lang) => (
<link
rel="alternate"
@@ -30,5 +30,5 @@ const {langData, siteMetadata, pathName} = Astro.props as Props;
}
href-lang={lang}
/>
))}
)) : null}

View File

@@ -32,13 +32,13 @@ const {
langData ? fileToOpenGraphConverter(langData.currentLang) : "en"
}
/>
{langData?.otherLangs &&
{langData?.otherLangs?.length ?
langData.otherLangs.map((lang) => (
<meta
property="og:locale:alternate"
content={fileToOpenGraphConverter(lang)}
/>
))}
)) : null}
<meta property="og:description" content={metaDescription} />
<meta property="og:image" content={metaImage} />
<meta property="og:type" content={ogType} />

View File

@@ -24,6 +24,6 @@ const {
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content={siteMetadata.twitterHandle} />
<meta name="twitter:image" content={metaImage} />
{type === "article" && unicornsData!.length === 1 && uniTwitter ? (
{type === "article" && unicornsData?.length === 1 && uniTwitter ? (
<meta property="twitter:creator" content={`@${uniTwitter}`} />
) : null}

View File

@@ -45,10 +45,11 @@ const otherLangs = translations
---
<Document>
<TabsScript/>
<TabsScript slot="head"/>
<!-- TODO: Add this -->
<!-- pathName={router.asPath} -->
<SEO
slot="head"
title={post.title}
description={post.description || post.excerpt}
unicornsData={post.authors}