moved utils
This commit is contained in:
parent
7328964564
commit
bee3d86df7
6 changed files with 2690 additions and 6 deletions
3
functions/utils/getId.js
Normal file
3
functions/utils/getId.js
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function getId(urlPath) {
|
||||
return urlPath.match(/([^\/]*)\/*$/)[0]
|
||||
}
|
||||
|
|
@ -5,6 +5,12 @@ module.exports = {
|
|||
author: `@gatsbyjs`,
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
resolve: `gatsby-plugin-netlify-identity`,
|
||||
options: {
|
||||
url: `gracious-johnson-d124e9.netlify.com` // required!
|
||||
}
|
||||
},
|
||||
`gatsby-plugin-react-helmet`,
|
||||
{
|
||||
resolve: `gatsby-source-filesystem`,
|
||||
|
|
|
|||
2657
package-lock.json
generated
2657
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
|
@ -9,6 +9,7 @@
|
|||
"gatsby": "^2.17.6",
|
||||
"gatsby-image": "^2.2.30",
|
||||
"gatsby-plugin-manifest": "^2.2.25",
|
||||
"gatsby-plugin-netlify-identity": "0.0.3",
|
||||
"gatsby-plugin-offline": "^3.0.17",
|
||||
"gatsby-plugin-react-helmet": "^3.1.13",
|
||||
"gatsby-plugin-sharp": "^2.2.34",
|
||||
|
|
|
|||
29
src/pages/login.js
Normal file
29
src/pages/login.js
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// src/components/Layout.js
|
||||
import React from "react"
|
||||
import IdentityModal, { useIdentityContext } from "react-netlify-identity-widget"
|
||||
import "react-netlify-identity-widget/styles.css" // delete if you want to bring your own CSS
|
||||
|
||||
const Layout = ({ children }) => {
|
||||
const identity = useIdentityContext()
|
||||
const [dialog, setDialog] = React.useState(false)
|
||||
const name =
|
||||
(identity && identity.user && identity.user.user_metadata && identity.user.user_metadata.name) || "NoName"
|
||||
|
||||
console.log(JSON.stringify(identity))
|
||||
const isLoggedIn = identity && identity.isLoggedIn
|
||||
return (
|
||||
<>
|
||||
<nav style={{ background: "green" }}>
|
||||
{" "}
|
||||
Login Status:
|
||||
<button className="btn" onClick={() => setDialog(true)}>
|
||||
{isLoggedIn ? `Hello ${name}, Log out here!` : "LOG IN"}
|
||||
</button>
|
||||
</nav>
|
||||
<main>{children}</main>
|
||||
<IdentityModal showDialog={dialog} onCloseDialog={() => setDialog(false)} />
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default Layout
|
||||
Loading…
Add table
Add a link
Reference in a new issue