-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
15 changed files
with
777 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,65 @@ | ||
import Head from 'next/head'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
|
||
export default function Header() { | ||
export default function Header({ siteName, menus, socials }: HeaderProps) { | ||
return ( | ||
<Head> | ||
<title> nextjs-paper </title> | ||
</Head> | ||
<header className="header"> | ||
<h1 className="logo"> | ||
<Link href="/"> | ||
<a className="site-name">{siteName}</a> | ||
</Link> | ||
{/* eslint-disable-next-line jsx-a11y/anchor-has-content */} | ||
<a className="btn-dark" /> | ||
</h1> | ||
<MenuNav menus={menus} /> | ||
<SocialNav socials={socials} /> | ||
</header> | ||
) | ||
} | ||
|
||
export interface HeaderProps { | ||
siteName: string, | ||
menus: MenuProps[], | ||
socials: SocialProps[] | ||
} | ||
|
||
function MenuNav({ menus }: {menus: MenuProps[]}) { | ||
const router = useRouter() | ||
return ( | ||
<nav className="menu"> | ||
{menus.map((menu) => ( | ||
<Link href={menu.href}> | ||
<a className={router.pathname === menu.href ? 'active' : ''}>{menu.name}</a> | ||
</Link> | ||
))} | ||
</nav> | ||
) | ||
} | ||
|
||
interface MenuProps { | ||
name: string, | ||
href: string | ||
} | ||
|
||
function SocialNav({ socials }: {socials: SocialProps[]}) { | ||
return ( | ||
<nav className="social"> | ||
{socials | ||
.filter((social) => social.id) | ||
.map((social) => ( | ||
<a href={`//${social.name}.com/${social.id}`}> | ||
<img | ||
id={social.name} | ||
src={`./${social.name}.svg`} | ||
alt={`${social.name}`} | ||
/> | ||
</a> | ||
))} | ||
</nav> | ||
) | ||
} | ||
|
||
interface SocialProps { | ||
name: 'instagram' | 'github' | 'twitter', | ||
id?: string | ||
} |
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,15 @@ | ||
import Document, { Head, Html, Main, NextScript } from 'next/document' | ||
|
||
export default class MyDocument extends Document { | ||
render() { | ||
return ( | ||
<Html> | ||
<Head /> | ||
<body className="not-ready" data-menu="true"> | ||
<Main /> | ||
<NextScript /> | ||
</body> | ||
</Html> | ||
) | ||
} | ||
} |
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,9 +1,22 @@ | ||
import Header from '../components/Header'; | ||
import Header, { HeaderProps } from '../components/Header'; | ||
|
||
function Index() { | ||
export default function Index({ siteName, menus, socials }: HeaderProps) { | ||
return ( | ||
<Header /> | ||
<Header siteName={siteName} menus={menus} socials={socials} /> | ||
) | ||
} | ||
|
||
export default Index | ||
export async function getStaticProps(): Promise<{ props: HeaderProps }> { | ||
const siteName = process.env.SITE_NAME ? process.env.SITE_NAME : 'Paper' | ||
return { | ||
props: { | ||
siteName, | ||
menus: [{ name: 'About', href: '/about' }], | ||
socials: [ | ||
{ name: 'github', id: process.env.GITHUB }, | ||
{ name: 'twitter', id: process.env.TWITTER }, | ||
{ name: 'instagram', id: process.env.INSTAGRAM }, | ||
], | ||
}, | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.