aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2022-01-07 12:42:12 +0100
committerArmand Philippot <git@armandphilippot.com>2022-01-07 12:42:12 +0100
commit09e0e2d1569e5098c960299746f7b8632e9b35f3 (patch)
tree66025d936f6659e7df8e57374fd729f1a5e18e53 /src
parentb405ddb76f217ccf7828b422ec4c0f0e15b7dee4 (diff)
fix: check for undefined meta in post header
The meta object can exists but its properties can be undefined. So I don't want to display the dl if all properties are undefined.
Diffstat (limited to 'src')
-rw-r--r--src/components/PostHeader/PostHeader.tsx12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/components/PostHeader/PostHeader.tsx b/src/components/PostHeader/PostHeader.tsx
index 2cdc39e..7046790 100644
--- a/src/components/PostHeader/PostHeader.tsx
+++ b/src/components/PostHeader/PostHeader.tsx
@@ -15,6 +15,16 @@ const PostHeader = ({
meta?: ArticleMeta;
title: string;
}) => {
+ const hasMeta = () => {
+ return (
+ meta?.author ||
+ meta?.commentCount ||
+ meta?.dates ||
+ meta?.thematics ||
+ meta?.website
+ );
+ };
+
return (
<header className={styles.wrapper}>
<div className={styles.body}>
@@ -26,7 +36,7 @@ const PostHeader = ({
)}
{title}
</h1>
- {meta && <PostMeta mode="single" meta={meta} />}
+ {meta && hasMeta() && <PostMeta mode="single" meta={meta} />}
{intro && (
<div
className={styles.intro}