-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(e2e-tests): Migrate E2E tests to Head API (#36182)
* migrate development-runtime to Head API * use next * migrate path-prefix e2e * modify development-runtime e2e to use PascalCase "Seo" component * migrate production-runtime e2e to Head API * update all Seo component to take title prop * remove outdated comment * move Seo to head export * Update e2e-tests/path-prefix/package.json Co-authored-by: Ty Hopp <[email protected]> * pass correct prop * remove Seo elem from body * format Co-authored-by: Ty Hopp <[email protected]>
- Loading branch information
1 parent
7d906de
commit 03ee426
Showing
66 changed files
with
367 additions
and
190 deletions.
There are no files selected for viewing
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,58 @@ | ||
import React from "react" | ||
import PropTypes from "prop-types" | ||
import Helmet from "react-helmet" | ||
import { StaticQuery, graphql } from "gatsby" | ||
import { graphql, useStaticQuery } from "gatsby" | ||
|
||
function Seo({ children, description, lang, keywords, title }) { | ||
const data = useStaticQuery(graphql` | ||
query DefaultSEOQuery { | ||
site { | ||
siteMetadata { | ||
title | ||
description | ||
social { | ||
} | ||
} | ||
} | ||
} | ||
`) | ||
|
||
const metaDescription = description || data.site.siteMetadata.description | ||
|
||
function SEO({ description, lang, meta, keywords, title }) { | ||
return ( | ||
<StaticQuery | ||
query={detailsQuery} | ||
render={data => { | ||
const metaDescription = | ||
description || data.site.siteMetadata.description | ||
return ( | ||
<Helmet | ||
htmlAttributes={{ | ||
lang, | ||
}} | ||
title={title} | ||
titleTemplate={`%s | ${data.site.siteMetadata.title}`} | ||
meta={[ | ||
{ | ||
name: `description`, | ||
content: metaDescription, | ||
}, | ||
{ | ||
property: `og:title`, | ||
content: title, | ||
}, | ||
{ | ||
property: `og:description`, | ||
content: metaDescription, | ||
}, | ||
{ | ||
property: `og:type`, | ||
content: `website`, | ||
}, | ||
{ | ||
name: `twitter:card`, | ||
content: `summary`, | ||
}, | ||
{ | ||
name: `twitter:creator`, | ||
content: data.site.siteMetadata.social.twitter, | ||
}, | ||
{ | ||
name: `twitter:title`, | ||
content: title, | ||
}, | ||
{ | ||
name: `twitter:description`, | ||
content: metaDescription, | ||
}, | ||
] | ||
.concat( | ||
keywords.length > 0 | ||
? { | ||
name: `keywords`, | ||
content: keywords.join(`, `), | ||
} | ||
: [] | ||
) | ||
.concat(meta)} | ||
/> | ||
) | ||
}} | ||
/> | ||
<> | ||
<title> | ||
{title ? `${title} | ${data.site.siteMetadata.title}` : title} | ||
</title> | ||
<html lang={lang} /> | ||
<meta name="description" content={metaDescription} /> | ||
<meta name="og:title" content={title} /> | ||
<meta name="og:description" content={metaDescription} /> | ||
<meta name="twitter:card" content="summary" /> | ||
<meta | ||
name="twitter:creator" | ||
content={data.site.siteMetadata.social.twitter} | ||
/> | ||
<meta name="twitter:title" content={title} /> | ||
<meta name="twitter:description" content={metaDescription} /> | ||
<meta name="og:type" content="website" /> | ||
<meta name="keywords" content={keywords && keywords.join(",")} /> | ||
{children} | ||
</> | ||
) | ||
} | ||
|
||
SEO.defaultProps = { | ||
Seo.defaultProps = { | ||
lang: `en`, | ||
meta: [], | ||
keywords: [], | ||
title: ``, | ||
} | ||
|
||
SEO.propTypes = { | ||
Seo.propTypes = { | ||
description: PropTypes.string, | ||
title: PropTypes.string, | ||
lang: PropTypes.string, | ||
meta: PropTypes.array, | ||
keywords: PropTypes.arrayOf(PropTypes.string), | ||
title: PropTypes.string.isRequired, | ||
} | ||
|
||
export default SEO | ||
|
||
const detailsQuery = graphql` | ||
query DefaultSEOQuery { | ||
site { | ||
siteMetadata { | ||
title | ||
description | ||
social { | ||
} | ||
} | ||
} | ||
} | ||
` | ||
export default Seo |
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
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
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
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
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
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
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
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
Oops, something went wrong.