Last active
October 22, 2020 06:41
-
-
Save dabit3/d4921b5fcda3b2821cfbcea6ecf0c54e to your computer and use it in GitHub Desktop.
Next.js + Amplify - pages/_app.js
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
// pages/_app.js | |
import '../styles/globals.css'; | |
import { css } from 'emotion'; | |
import Link from 'next/link'; | |
import checkUser from '../helpers/checkUser'; | |
import '../configureAmplify'; | |
export default function MyApp({ Component, pageProps }) { | |
const user = checkUser(); | |
return ( | |
<div> | |
<nav className={navStyle}> | |
<AppLink title="Home" path="/" /> | |
<AppLink title="Profile" path="/profile" /> | |
{ user && <AppLink title="Create Post" path="/create-post" /> } | |
</nav> | |
<Component {...pageProps} /> | |
</div> | |
) | |
} | |
const AppLink = ({ title, path }) => ( | |
<Link href={path}> | |
<span className={linkStyle}>{title}</span> | |
</Link> | |
) | |
const linkStyle = css` | |
margin-right: 20px; | |
cursor: pointer; | |
` | |
const navStyle = css` | |
display: flex; | |
padding: 30px; | |
border-bottom: 1px solid #ddd; | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment