Created
August 31, 2020 02:25
-
-
Save trevorblades/1cd7068c57e555e3ed6c1a4768d03544 to your computer and use it in GitHub Desktop.
Auto-generated social images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import PageLayout from './PageLayout'; | |
import PropTypes from 'prop-types'; | |
import React from 'react'; | |
import getShareImage from '@jlengstorf/get-share-image'; | |
import {Helmet} from 'react-helmet'; | |
export default function PostLayout({children, pageContext}) { | |
const {title, description, tags} = pageContext.frontmatter; | |
const shareImage = getShareImage({ | |
title, | |
tagline: description, | |
cloudName: 'dybmuhvem', | |
imagePublicID: 'template_ijwmdw', | |
titleFont: 'montserrat-bold.ttf', | |
taglineFont: 'montserrat-regular.ttf', | |
textColor: '1A202C' | |
}); | |
return ( | |
<PageLayout pageContext={pageContext}> | |
<Helmet title={title}> | |
<meta name="description" content={description} /> | |
<meta name="image" content={shareImage} /> | |
<meta property="og:image" content={shareImage} /> | |
</Helmet> | |
some extra blog stuff | |
<ul> | |
{tags?.map((tag, index) => ( | |
<li key={index}>{tag}</li> | |
))} | |
</ul> | |
{children} | |
</PageLayout> | |
); | |
} | |
PostLayout.propTypes = { | |
children: PropTypes.node.isRequired, | |
pageContext: PropTypes.object.isRequired | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
VOD: https://www.youtube.com/watch?v=Idc6Kn3YJ_A
@jlengstorf/get-share-image
: https://www.npmjs.com/package/@jlengstorf/get-share-imageSocial card design template: https://www.learnwithjason.dev/blog/design-social-sharing-card/
In the video, I go through getting your
imagePublicID
by uploading your template image to Cloudinary, uploading fonts to use in your share image, and designing the template.