-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from wedinc/feat/migrate-to-app-router-part1
Migration part1
- Loading branch information
Showing
6 changed files
with
86 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
'use client' | ||
|
||
import { signOut } from "next-auth/react" | ||
|
||
const SignoutButton = () => { | ||
return ( | ||
<button className='btn btn-secondary' onClick={() => signOut()}> | ||
Sign out | ||
</button> | ||
) | ||
} | ||
|
||
export default SignoutButton |
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 ListItem, { ListItemProps } from '@/components/ListItem' | ||
import Link from 'next/link' | ||
import SignoutButton from '../_components/SignoutButton' | ||
|
||
export default async function Caramel() { | ||
const res = await fetch('https://hacker-news.firebaseio.com/v0/newstories.json') | ||
const ids: number[] = await res.json() | ||
|
||
const slicedIds = ids.slice(0, 10) | ||
const articles = await Promise.all(slicedIds.map(async (id) => { | ||
const res = await fetch(`https://hacker-news.firebaseio.com/v0/item/${id}.json`) | ||
return await res.json() as ListItemProps | ||
})) | ||
|
||
return ( | ||
<div className='bg-[#bc611e] p-8'> | ||
<h1 className='text-3xl font-bold underline text-gray-300'>Hello Caramel!</h1> | ||
<Link href='/' className='btn btn-primary'> | ||
Back | ||
</Link> | ||
<ul className='flex flex-col gap-4 w-1/3'> | ||
{articles.map((article) => { | ||
const newArticle = { ...article, title: article.title.repeat(2) } | ||
return <ListItem {...newArticle} key={newArticle.title} className='h-36' /> | ||
})} | ||
</ul> | ||
<SignoutButton /> | ||
</div> | ||
) | ||
} |
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,18 @@ | ||
export const metadata = { | ||
title: 'Next.js', | ||
description: 'Generated by Next.js', | ||
} | ||
|
||
import '../styles/globals.css' | ||
|
||
export default function RootLayout({ | ||
children, | ||
}: { | ||
children: React.ReactNode | ||
}) { | ||
return ( | ||
<html lang="en"> | ||
<body>{children}</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
This file was deleted.
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