fix pages without frontmatter showing invalid date
This commit is contained in:
parent
02e3b31de2
commit
55811517a6
|
|
@ -10,15 +10,9 @@ export default function Page({ body, ...rest }) {
|
||||||
const children = {
|
const children = {
|
||||||
Component,
|
Component,
|
||||||
frontmatter: {
|
frontmatter: {
|
||||||
title: rest.title,
|
...rest,
|
||||||
date: rest.date,
|
date: rest.date === "Invalid Date" ? null : rest.date,
|
||||||
description: rest.description,
|
created: rest.created === "Invalid Date" ? null : rest.created
|
||||||
image: rest.image,
|
|
||||||
youtube: rest.youtube,
|
|
||||||
podcast: rest.podcast,
|
|
||||||
featured: rest.featured,
|
|
||||||
created: rest.created,
|
|
||||||
aliases: rest.aliases
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -28,19 +22,22 @@ export default function Page({ body, ...rest }) {
|
||||||
.replace(/-/g, " ")
|
.replace(/-/g, " ")
|
||||||
// capitalize first char of each word
|
// capitalize first char of each word
|
||||||
.replace(/(^\w{1})|(\s{1}\w{1})/g, (str) => str.toUpperCase());
|
.replace(/(^\w{1})|(\s{1}\w{1})/g, (str) => str.toUpperCase());
|
||||||
|
|
||||||
|
const title = children.frontmatter.title ?? titleFromUrl
|
||||||
|
const imageUrl = siteConfig.url + children.frontmatter.image
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<NextSeo
|
<NextSeo
|
||||||
title={children.frontmatter.title ?? titleFromUrl}
|
title={title}
|
||||||
description={children.frontmatter.description}
|
description={children.frontmatter.description}
|
||||||
canonical={siteConfig.url + "/" + rest._raw.flattenedPath}
|
canonical={`${siteConfig.url}/${rest._raw.flattenedPath}`}
|
||||||
openGraph={{
|
openGraph={{
|
||||||
title: children.frontmatter.title ?? titleFromUrl,
|
title: title,
|
||||||
description: children.frontmatter.description,
|
description: children.frontmatter.description,
|
||||||
images: [
|
images: [
|
||||||
{
|
{
|
||||||
url: siteConfig.url + children.frontmatter.image,
|
url: imageUrl,
|
||||||
width: 1200,
|
width: 1200,
|
||||||
height: 627,
|
height: 627,
|
||||||
alt: children.frontmatter.title,
|
alt: children.frontmatter.title,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue