Skip to content

Commit 65b9753

Browse files
committed
feat: add simple SEO component
1 parent a8014f5 commit 65b9753

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

components/SEO.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import Head from "next/head";
2+
3+
export default function SEO({ title, description }) {
4+
return (
5+
<Head>
6+
<title>{title}</title>
7+
<meta name="description" content={description} />
8+
<meta property="og:title" content={title} />
9+
</Head>
10+
);
11+
}

pages/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ import Header from "../components/Header";
66
import Layout, { GradientBackground } from "../components/Layout";
77
import ArrowIcon from "../components/ArrowIcon";
88
import { getGlobalData } from "../utils/globalData";
9+
import SEO from "../components/SEO";
910

1011
export default function Index({ posts, globalData }) {
1112
return (
1213
<Layout>
14+
<SEO title={globalData.name} description={globalData.blogTitle} />
1315
<Header name={globalData.name} />
1416
<main className="w-full">
1517
<h1 className="text-3xl lg:text-5xl text-center mb-12">

pages/posts/[slug].js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import CustomLink from "../../components/CustomLink";
1414
import Footer from "../../components/Footer";
1515
import Header from "../../components/Header";
1616
import Layout, { GradientBackground } from "../../components/Layout";
17+
import SEO from "../../components/SEO";
1718

1819
// Custom components/renderers to pass to MDX.
1920
// Since the MDX files aren't loaded by webpack, they have no knowledge of how
@@ -36,6 +37,10 @@ export default function PostPage({
3637
}) {
3738
return (
3839
<Layout>
40+
<SEO
41+
title={`${frontMatter.title} - ${globalData.name}`}
42+
description={frontMatter.description}
43+
/>
3944
<Header name={globalData.name} />
4045
<article className="px-6 md:px-0">
4146
<header>

0 commit comments

Comments
 (0)