Skip to content

Commit 159ecd7

Browse files
authored
Merge pull request #49 from DoctorDerek/fix-error-if-twitter-undefined-in-siteMetadata
fix: make siteMetadata.twitter optional to fix TypeError
2 parents 8dbcf16 + a9170a9 commit 159ecd7

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

layouts/PostLayout.js

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,19 @@ export default function PostLayout({ children, frontMatter, next, prev }) {
5151
<dl className="text-sm font-medium leading-5 whitespace-nowrap">
5252
<dt className="sr-only">Name</dt>
5353
<dd className="text-gray-900 dark:text-gray-100">{siteMetadata.author}</dd>
54-
<dt className="sr-only">Twitter</dt>
55-
<dd>
56-
<Link
57-
href={siteMetadata.twitter}
58-
className="text-blue-500 hover:text-blue-600 dark:hover:text-blue-400"
59-
>
60-
{siteMetadata.twitter.replace('https://twitter.com/', '@')}
61-
</Link>
62-
</dd>
54+
{typeof siteMetadata.twitter === 'string' && (
55+
<>
56+
<dt className="sr-only">Twitter</dt>
57+
<dd>
58+
<Link
59+
href={siteMetadata.twitter}
60+
className="text-blue-500 hover:text-blue-600 dark:hover:text-blue-400"
61+
>
62+
{siteMetadata.twitter.replace('https://twitter.com/', '@')}
63+
</Link>
64+
</dd>
65+
</>
66+
)}
6367
</dl>
6468
</li>
6569
</ul>

0 commit comments

Comments
 (0)