-
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
21 changed files
with
1,188 additions
and
239 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,11 @@ | ||
export default function AboutPage() { | ||
return ( | ||
<div className="container"> | ||
<h1>About</h1> | ||
<p>A simple blog example with Jsonplaceholder API and Nexjs</p> | ||
<a href="https://github.com/bioodev">Designed by Bioodev</a> | ||
|
||
</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,9 @@ | ||
import React from 'react' | ||
|
||
const Footer = () => { | ||
return ( | ||
<div className='container footer'><a href="https://github.com/bioodev">@bioodev</a></div> | ||
) | ||
} | ||
|
||
export default Footer |
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,26 @@ | ||
import React from "react"; | ||
import Link from "next/link"; | ||
import "./Navbar.module.css" | ||
|
||
const Navbar = () => { | ||
const links = [ | ||
{ label: "Home", route: "/", icon:"💎" }, | ||
{ label: "Posts", route: "/posts", icon:"📄" }, | ||
{ label: "About", route: "/about", icon:"💻" }, | ||
]; | ||
return ( | ||
<> | ||
<nav className="container"> | ||
<ul className="navlist"> | ||
{links.map(({ label, route, icon }) => ( | ||
<li key={route}> | ||
<Link href={route}>{icon} {label}</Link> | ||
</li> | ||
))} | ||
</ul> | ||
</nav> | ||
</> | ||
); | ||
}; | ||
|
||
export default Navbar; |
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 @@ | ||
|
||
.nav{ | ||
background-color: black; | ||
display: inline-flex; | ||
} | ||
.nav li{ | ||
background-color: black; | ||
display: inline-flex; | ||
} | ||
.nav li a{ | ||
background-color: black; | ||
display: inline-flex; | ||
} |
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,9 @@ | ||
export default function Head() { | ||
return ( | ||
<> | ||
<title>srndp</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
</> | ||
); | ||
} | ||
|
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,20 @@ | ||
import Navbar from "./components/Navbar"; | ||
import Footer from "./components/Footer"; | ||
import "../styles/globals.css" | ||
export default function RootLayout({ children }) { | ||
|
||
return ( | ||
<html lang="es"> | ||
<head /> | ||
<body> | ||
<header> | ||
<Navbar /> | ||
</header> | ||
{children} | ||
<footer> | ||
<Footer /> | ||
</footer> | ||
</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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import Link from "next/link"; | ||
|
||
export default function HomePage() { | ||
return ( | ||
<div className="container"> | ||
<h1>🏴 Blog</h1> | ||
<h3>A simple example blog with Nextjs and API</h3> | ||
<Link className="button" href={"/posts"}>Check list of posts</Link> | ||
</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,20 @@ | ||
import Link from "next/link" | ||
const fetchPosts = () => { | ||
return fetch("https://jsonplaceholder.typicode.com/users/1/posts") | ||
.then(res => res.json()) | ||
.catch(err => console.log(err)) | ||
} | ||
|
||
export async function ListOfPosts() { | ||
const posts = await fetchPosts() | ||
return posts.slice(0, 15).map(post => ( | ||
<Link className="articles" href={`/posts/${post.id}`} key={post.id}> | ||
<h2> | ||
{post.title} | ||
</h2> | ||
<p> | ||
{post.body} | ||
</p> | ||
</Link> | ||
)) | ||
} |
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,24 @@ | ||
import React from "react"; | ||
|
||
export async function PostDetail({ id }) { | ||
const fetchPost = () => { | ||
return fetch(`https://jsonplaceholder.typicode.com/users/1/posts?id=${id}`) | ||
.then((res) => res.json()) | ||
.catch((err) => console.log(err)); | ||
}; | ||
const post = await fetchPost(); | ||
const { title, body } = post[0]; | ||
console.log(id); | ||
console.log(post); | ||
console.log(title); | ||
return ( | ||
<div className="container"> | ||
{title && body && ( | ||
<> | ||
<h1>{title}</h1> | ||
<div>{body}</div> | ||
</> | ||
)} | ||
</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,11 @@ | ||
import { PostDetail } from "./PostDetail"; | ||
|
||
export default function PostsPage({ params }) { | ||
const { id } = params; | ||
|
||
return ( | ||
<> | ||
<PostDetail id={id} /> | ||
</> | ||
); | ||
} |
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,11 @@ | ||
import { ListOfPosts } from "./ListOfPosts"; | ||
|
||
export default function PostsPage() { | ||
return ( | ||
<div className="container postslist"> | ||
<h1>Blog posts</h1> | ||
<ListOfPosts /> | ||
</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
Oops, something went wrong.
202e4c8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
blog-nextjs-api – ./
blog-nextjs-api.vercel.app
blog-nextjs-api-bioodev.vercel.app
blog-nextjs-api-git-main-bioodev.vercel.app