This repository has been archived by the owner on Oct 27, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3024944
commit b811379
Showing
16 changed files
with
180 additions
and
94 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import React from 'react' | ||
import Helmet from 'react-helmet' | ||
import { withRouter, RouteComponentProps } from 'react-router-dom' | ||
import meta from '../../data/meta.json' | ||
import imageDefault from '../../img/share.png' | ||
|
||
const MetaTags = ({ | ||
title, | ||
description, | ||
url, | ||
image | ||
}: { | ||
title: string | ||
description: string | ||
url: string | ||
image: string | ||
}) => ( | ||
<Helmet defaultTitle={meta.title} titleTemplate={`%s - ${meta.title}`}> | ||
<html lang="en" /> | ||
|
||
{title && <title>{title}</title>} | ||
|
||
{/* General tags */} | ||
<meta name="description" content={description} /> | ||
<meta name="image" content={image} /> | ||
<link rel="canonical" href={url} /> | ||
|
||
{/* OpenGraph tags */} | ||
<meta property="og:url" content={url} /> | ||
<meta property="og:title" content={title} /> | ||
<meta property="og:description" content={description} /> | ||
<meta property="og:image" content={image} /> | ||
|
||
{/* Twitter Card tags */} | ||
<meta name="twitter:card" content="summary_large_image" /> | ||
<meta name="twitter:creator" content="@oceanprotocol" /> | ||
<meta name="twitter:title" content={title} /> | ||
<meta name="twitter:description" content={description} /> | ||
<meta name="twitter:image" content={image} /> | ||
|
||
{/* Prevent search engine indexing except for live */} | ||
{window.location.hostname !== 'commons.oceanprotocol.com' && ( | ||
<meta name="robots" content="noindex,nofollow" /> | ||
)} | ||
</Helmet> | ||
) | ||
|
||
interface SeoProps extends RouteComponentProps { | ||
title?: string | ||
description?: string | ||
shareImage?: string | ||
} | ||
|
||
const Seo = ({ title, description, shareImage, location }: SeoProps) => { | ||
title = title || meta.title | ||
description = description || meta.description | ||
shareImage = shareImage || meta.url + imageDefault | ||
|
||
const url = meta.url + location.pathname + location.search | ||
|
||
return ( | ||
<MetaTags | ||
title={title} | ||
description={description} | ||
url={url} | ||
image={shareImage} | ||
/> | ||
) | ||
} | ||
|
||
export default withRouter(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,59 @@ | ||
import React from 'react' | ||
import Helmet from 'react-helmet' | ||
import Content from '../atoms/Content' | ||
import styles from './Route.module.scss' | ||
import meta from '../../data/meta.json' | ||
import Markdown from '../atoms/Markdown' | ||
import Seo from '../atoms/Seo' | ||
|
||
interface RouteProps { | ||
title: string | ||
description?: string | ||
image?: any | ||
shareImage?: string | ||
children: any | ||
wide?: boolean | ||
className?: string | ||
} | ||
|
||
const Route = ({ | ||
title, | ||
description, | ||
image, | ||
shareImage, | ||
wide, | ||
children, | ||
className | ||
}: { | ||
title: string | ||
description?: string | ||
image?: any | ||
children: any | ||
wide?: boolean | ||
className?: string | ||
}) => ( | ||
<div className={className}> | ||
<Helmet defaultTitle={meta.title} titleTemplate={`%s - ${meta.title}`}> | ||
{/* Strip HTML from passed title */} | ||
<title>{title.replace(/(<([^>]+)>)/gi, '')}</title> | ||
{description && <meta name="description" content={description} />} | ||
</Helmet> | ||
|
||
<article> | ||
<header className={styles.header}> | ||
<Content wide={wide}> | ||
<h1 className={styles.title}>{title}</h1> | ||
|
||
{image && image} | ||
|
||
{description && ( | ||
<Markdown | ||
text={description} | ||
className={styles.description} | ||
/> | ||
)} | ||
</Content> | ||
</header> | ||
|
||
{children} | ||
</article> | ||
</div> | ||
) | ||
}: RouteProps) => { | ||
// Strip HTML from passed title | ||
const titleSanitized = title.replace(/(<([^>]+)>)/gi, '') | ||
|
||
return ( | ||
<div className={className}> | ||
<Seo | ||
title={titleSanitized} | ||
description={description} | ||
shareImage={shareImage} | ||
/> | ||
|
||
<article> | ||
<header className={styles.header}> | ||
<Content wide={wide}> | ||
<h1 className={styles.title}>{titleSanitized}</h1> | ||
|
||
{image && image} | ||
|
||
{description && ( | ||
<Markdown | ||
text={description} | ||
className={styles.description} | ||
/> | ||
)} | ||
</Content> | ||
</header> | ||
|
||
{children} | ||
</article> | ||
</div> | ||
) | ||
} | ||
|
||
export default Route |
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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,10 +1,15 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import { MemoryRouter } from 'react-router' | ||
import About from './About' | ||
|
||
describe('About', () => { | ||
it('renders without crashing', () => { | ||
const { container } = render(<About />) | ||
const { container } = render( | ||
<MemoryRouter> | ||
<About /> | ||
</MemoryRouter> | ||
) | ||
expect(container.firstChild).toBeInTheDocument() | ||
}) | ||
}) |
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,10 +1,15 @@ | ||
import React from 'react' | ||
import { render } from '@testing-library/react' | ||
import NotFound from './NotFound' | ||
import { MemoryRouter } from 'react-router' | ||
|
||
describe('NotFound', () => { | ||
it('renders without crashing', () => { | ||
const { container } = render(<NotFound />) | ||
const { container } = render( | ||
<MemoryRouter> | ||
<NotFound /> | ||
</MemoryRouter> | ||
) | ||
expect(container.firstChild).toBeInTheDocument() | ||
}) | ||
}) |
Oops, something went wrong.