Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1508: Port SEO from Gatsby to Nextjs #1509

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/frontend/next/src/components/SearchHelp/SEO.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { FC } from 'react';
import Head from 'next/head';
import useSiteMetadata from '../hooks/use-site-metadata';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The site-metadata hook isn't going to work as is, since it uses graphql to talk to Gatsby. We'll have to figure out a plan for passing data into next components from the build statically, maybe as env variables or maybe using static props. I know that others are thinking about this too.


interface Props {
description: string;
lang: string;
title: string;
}

const SEO: FC<Props> = ({ description, lang, title }) => {
const siteMetadata = useSiteMetadata();
const metaDescription = description || siteMetadata.description;
return (
<Head>
<html lang={lang} />
<title>{`${title} | ${siteMetadata.title}`}</title>
<meta name="description" content={description} />
<meta property="og:title" content={title} />
<meta property="og:description" content={metaDescription} />
</Head>
);
};

export default SEO;