This repository has been archived by the owner on Jul 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 674
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
d7da5bb
commit b219695
Showing
17 changed files
with
217 additions
and
41 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
import * as React from "react"; | ||
|
||
import { default as MetaConsumer } from "./consumer"; | ||
import { MetaContextInterface, Provider as MetaProvider } from "./context"; | ||
|
||
interface MetaWrapperProps { | ||
meta: MetaContextInterface; | ||
children: React.ReactNode; | ||
} | ||
|
||
const MetaWrapper: React.SFC<MetaWrapperProps> = ({ children, meta }) => ( | ||
<MetaProvider value={meta}> | ||
<MetaConsumer>{children}</MetaConsumer> | ||
</MetaProvider> | ||
); | ||
|
||
export default MetaWrapper; |
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,30 @@ | ||
import * as React from "react"; | ||
import { Helmet } from "react-helmet"; | ||
|
||
import { Consumer as MetaConsumer } from "./context"; | ||
|
||
class Consumer extends React.Component { | ||
render() { | ||
return ( | ||
<MetaConsumer> | ||
{({ title, description, image, type, url, custom }) => ( | ||
<> | ||
<Helmet | ||
title={title} | ||
meta={[ | ||
{ name: "description", content: description }, | ||
{ property: "og:url", content: url }, | ||
{ property: "og:type", content: type }, | ||
{ property: "og:image", content: image }, | ||
...custom | ||
]} | ||
/> | ||
{this.props.children} | ||
</> | ||
)} | ||
</MetaConsumer> | ||
); | ||
} | ||
} | ||
|
||
export default Consumer; |
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,17 @@ | ||
import * as React from "react"; | ||
import { META_DEFAULTS } from "../../core/config"; | ||
|
||
type MetaProps = JSX.IntrinsicElements["meta"]; | ||
|
||
export interface MetaContextInterface { | ||
title?: string; | ||
description?: string; | ||
url?: string; | ||
image?: string; | ||
type?: string; | ||
custom?: MetaProps[]; | ||
} | ||
|
||
export const { Provider, Consumer } = React.createContext<MetaContextInterface>( | ||
META_DEFAULTS | ||
); |
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,3 @@ | ||
export { Provider as MetaProvider, MetaContextInterface } from "./context"; | ||
export { default as MetaConsumer } from "./consumer"; | ||
export { default as MetaWrapper } from "./MetaWrapper"; |
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,10 @@ | ||
// import * as React from "react"; | ||
// import { Helment } from "react-helmet"; | ||
|
||
// import { Provider as MetaProvider } from "./context"; | ||
|
||
// class Provider extends React.Component { | ||
// render() { | ||
// return <MetaProvider>{this.props.children}</MetaProvider>; | ||
// } | ||
// } |
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.