Skip to content
This repository was archived by the owner on Apr 19, 2021. It is now read-only.

Commit d0a8b84

Browse files
add meta preview to the blog posts. (#634)
Fixes gitpod-io/website#626
1 parent 64c069c commit d0a8b84

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

src/templates/blog.tsx

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -146,25 +146,28 @@ const StyledBlogTemplate = styled.div`
146146

147147

148148
const BlogTemplate: React.SFC<BlogTemplateProps> = ({ data }) => {
149-
const authors = parseAuthors(data.markdownRemark.frontmatter.author);
150-
return (
151-
<IndexLayout canonical={data.markdownRemark.frontmatter.url || `${data.markdownRemark.fields.slug.toLowerCase()}`}>
152-
<Helmet>
153-
<title>{data.markdownRemark.frontmatter.title}</title>
154-
<meta name="description" content={data.markdownRemark.frontmatter.subtitle} />
155-
<meta name="keywords" content="cloud ide, github, javascript, online ide, web ide, code review" />
156-
157-
<meta name="twitter:card" content="summary"></meta>
158-
<meta name="twitter:site" content="@gitpod"></meta>
159-
{authors.map(author => <meta name="twitter:creator" content={'@' + author.socialProfiles.twitter}></meta>)}
160-
161-
<meta property="og:url" content={data.site.siteMetadata.siteUrl + data.markdownRemark.fields.slug} />
162-
<meta property="og:title" content={data.markdownRemark.frontmatter.title} />
163-
<meta property="og:description" content={data.markdownRemark.excerpt} />
164-
<meta property="og:image" content={data.markdownRemark.frontmatter.image} />
165-
{
166-
data.markdownRemark.frontmatter.url ? <link rel="canonical" href={data.markdownRemark.frontmatter.url} /> : null
167-
}
149+
const authors = parseAuthors(data.markdownRemark.frontmatter.author);
150+
const metaPreview = `https://www.gitpod.io${data.markdownRemark.frontmatter.teaserImage ? data.markdownRemark.frontmatter.teaserImage : data.markdownRemark.frontmatter.image}`
151+
return (
152+
<IndexLayout canonical={data.markdownRemark.frontmatter.url || `${data.markdownRemark.fields.slug.toLowerCase()}`}>
153+
<Helmet>
154+
<title>{data.markdownRemark.frontmatter.title}</title>
155+
<meta name="description" content={data.markdownRemark.frontmatter.subtitle} />
156+
<meta name="keywords" content="cloud ide, github, javascript, online ide, web ide, code review" />
157+
158+
<meta name="twitter:card" content="summary"></meta>
159+
<meta name="twitter:site" content="@gitpod"></meta>
160+
{authors.map(author => <meta name="twitter:creator" content={'@' + author.socialProfiles.twitter}></meta>)}
161+
162+
<meta property="og:url" content={data.site.siteMetadata.siteUrl + data.markdownRemark.fields.slug} />
163+
<meta property="og:title" content={data.markdownRemark.frontmatter.title} />
164+
<meta property="og:description" content={data.markdownRemark.excerpt} />
165+
<meta property="og:image" content={metaPreview} />
166+
{
167+
data.markdownRemark.frontmatter.url ? <link rel="canonical" href={data.markdownRemark.frontmatter.url} /> : null
168+
}
169+
<meta name="twitter:image" content={metaPreview} />
170+
168171

169172
</Helmet>
170173
<div className="pattern pattern--full-vp-height" style={{marginBottom: '10rem'}}>

0 commit comments

Comments
 (0)