반응형
250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- logstash
- mariadb
- Python
- AWS
- 엘라스틱서치
- Git
- ssh
- docker
- unity
- 설정
- sample
- 영어
- Windows
- elasticsearch
- MySQL
- JS
- 유니티
- s3
- JavaScript
- Ai
- MSSQL
- build
- 구글
- Linux
- API
- ChatGPT
- nodejs
- Kibana
- error
Archives
- Today
- Total
가끔 보자, 하늘.
NextJS/Link, Component, Router - Only Code 본문
(Hello Page 만들기-https://ongamedev.tistory.com/498- 코드에서 이어집니다.)
mkdir components && cd "$_"
vi header.js
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import Link from 'next/link'
const linkStyle={marginRight: 15}
export default () => (
<div>
<Link href="/">
<a style={linkStyle}> Home </a>
</Link>
<Link href="/admin">
<a style={linkStyle}> Admin </a>
</Link>
</div>
)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
vi layout.js
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import Header from '/components/header'
const layoutStyle = {
margin: 10,
padding: 10,
border: '1px soild #DDD'
}
export default (props) => (
<div style={layoutStyle}>
<Header />
{props.children}
</div>
)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
cd .. && cd pages && mkdir admin && cd "$_"
vi index.js
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import Layout from '/components/layout'
import Link from 'next/link'
const MenuLink = (props) => (
<li>
<Link href={{
pathname: '/admin/menu',
query: {title:props.title}
}}>
<a>{props.title}</a>
</Link>
</li>
)
export default () => (
<Layout>
<h1> Admin Menu </h1>
<ul>
<MenuLink title="Dashboard" />
<MenuLink title="Management" />
</ul>
</Layout>
)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
vi menu.js
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
import Layout from '/components/layout'
import { withRouter } from 'next/router';
const Menu = ({router:{query}}) => {
if(query.title == "Dashboard"){
return(
<Layout>
<h1>{query.title}</h1>
</Layout>
)
}else if(query.title == "Management"){
return(
<Layout>
<h1>{query.title}</h1>
<p> <Link href="https://ongamedev.tistory.com/499">read detail</Link> </p>
</Layout>
)
}
}
export default withRouter(Menu)
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
cd .. && cd ..
npm run dev
(*full source code link)
반응형
'개발 이야기 > 개발 및 서비스' 카테고리의 다른 글
next-auth CredentialsProvider 에 추가 정보를 session.user에 추가하기 (2) | 2022.10.27 |
---|---|
NextJS/Tailwindcss, getServerSideProps - Only Code (0) | 2022.08.13 |
NextJS/Hello page 만들기 - Only Code (0) | 2022.08.11 |
AWS EC2의 메타 데이터를 확인하는 방법(feat. python) (0) | 2022.07.26 |
Windows에서의 ssh 인증 파일 permission 문제 해결 방법 (0) | 2022.07.25 |