Skip to content

Commit

Permalink
fix: improper use of null when interface asks for undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
FineWolf committed Jul 21, 2023
1 parent d6c6d52 commit 0447eb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/SEO.astro
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ function validateProps(props: Props) {
if (props.openGraph) {
if (
!props.openGraph.basic ||
props.openGraph.basic.title == null ||
props.openGraph.basic.type == null ||
props.openGraph.basic.image == null
(props.openGraph.basic.title ?? undefined) == undefined ||
(props.openGraph.basic.type ?? undefined) == undefined ||
(props.openGraph.basic.image ?? undefined) == undefined
) {
throw new Error(
"If you pass the openGraph prop, you have to at least define the title, type, and image basic properties!"
Expand Down
8 changes: 2 additions & 6 deletions src/components/OpenGraphImageTags.astro
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,5 @@ const { secureUrl, type, width, height, alt } = Astro.props.openGraph.image;
{secureUrl ? <meta property="og:image:secure_url" content={secureUrl} /> : null}
{type ? <meta property="og:image:type" content={type} /> : null}
{width ? <meta property="og:image:width" content={width} /> : null}
{
!(height === null) ? (
<meta property="og:image:height" content={height} />
) : null
}
{!(alt === null) ? <meta property="og:image:alt" content={alt} /> : null}
{height ? <meta property="og:image:height" content={height} /> : null}
{alt ? <meta property="og:image:alt" content={alt} /> : null}

0 comments on commit 0447eb3

Please sign in to comment.