Skip to content

Commit 83dacea

Browse files
authored
feat: update SEO (#30)
* feat: update SEO * feat: update OGP tags
1 parent 1379917 commit 83dacea

2 files changed

Lines changed: 51 additions & 1 deletion

File tree

src/components/PostSeo.jsx

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import * as React from 'react';
2+
3+
export function PostOgpSeo({ frontmatter }) {
4+
return (
5+
<>
6+
<meta property="og:title" content={frontmatter.title} />
7+
<meta property="og:type" content="article" />
8+
<meta property="article:published_time" content={frontmatter.date} />
9+
<meta property="article:author" content={frontmatter.author} />
10+
<meta
11+
property="og:image"
12+
content="https://html.sammy-codes.com/images/large-profile.jpg"
13+
/>
14+
<meta property="og:description" content="A one sentence description" />
15+
</>
16+
);
17+
}
18+
19+
export function PostTwitterSeo({ frontmatter }) {
20+
return (
21+
<>
22+
<meta name="twitter:card" content="summary_large_image" />
23+
<meta name="twitter:site" content="@lkpeto" />
24+
<meta name="twitter:title" content={frontmatter.title} />
25+
<meta
26+
name="twitter:description"
27+
content="Senior Selachimorpha at DigitalOcean"
28+
/>
29+
<meta
30+
name="twitter:image"
31+
content="https://html.sammy-codes.com/images/large-profile.jpg"
32+
/>
33+
</>
34+
);
35+
}
36+
37+
export function PostSeo({ frontmatter }) {
38+
return (
39+
<>
40+
<PostOgpSeo frontmatter={frontmatter} />
41+
<PostTwitterSeo frontmatter={frontmatter} />
42+
</>
43+
);
44+
}

src/pages/blog-posts/{mdx.frontmatter__slug}.jsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
import * as React from 'react';
22
import { PostLayout } from '../../components/PostLayout';
3+
import { PostSeo } from '../../components/PostSeo';
34

45
export const Head = ({ pageContext }) => {
56
const { frontmatter } = pageContext;
6-
return <title>{frontmatter.title}</title>;
7+
return (
8+
<>
9+
<title>{frontmatter.title}</title>
10+
<PostSeo frontmatter={frontmatter} />
11+
</>
12+
);
713
};
814

915
export default function PostPage({ pageContext, children }) {

0 commit comments

Comments
 (0)