Merge pull request #49 from DoctorDerek/fix-error-if-twitter-undefined-in-siteMetadata

fix: make siteMetadata.twitter optional to fix TypeError
This commit is contained in:
Timothy 2021-05-20 09:21:28 +08:00 committed by GitHub
commit 159ecd7d2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -51,15 +51,19 @@ export default function PostLayout({ children, frontMatter, next, prev }) {
<dl className="text-sm font-medium leading-5 whitespace-nowrap">
<dt className="sr-only">Name</dt>
<dd className="text-gray-900 dark:text-gray-100">{siteMetadata.author}</dd>
<dt className="sr-only">Twitter</dt>
<dd>
<Link
href={siteMetadata.twitter}
className="text-blue-500 hover:text-blue-600 dark:hover:text-blue-400"
>
{siteMetadata.twitter.replace('https://twitter.com/', '@')}
</Link>
</dd>
{typeof siteMetadata.twitter === 'string' && (
<>
<dt className="sr-only">Twitter</dt>
<dd>
<Link
href={siteMetadata.twitter}
className="text-blue-500 hover:text-blue-600 dark:hover:text-blue-400"
>
{siteMetadata.twitter.replace('https://twitter.com/', '@')}
</Link>
</dd>
</>
)}
</dl>
</li>
</ul>