Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added app/about/page.tsx
Empty file.
4 changes: 4 additions & 0 deletions app/blog/[...slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function BlogPost() {
return <div>post</div>

}
3 changes: 3 additions & 0 deletions app/blog/loading.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function BlogLoader() {
return <div>...loading...</div>
}
19 changes: 19 additions & 0 deletions app/blog/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import Link from "next/link"
import { getAllPosts } from "../../lib/cms"

export default async function Blog() {
const posts = await getAllPosts()

return (
<div>
{posts.map((post) => (
// eslint-disable-next-line react/jsx-key
<Link href={`/blog/${post.slug}`}>
<div>
<h1>{post.title}</h1>
</div>
</Link>
))}
</div>
)
}
30 changes: 30 additions & 0 deletions app/contact/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
'use client'

import { useState } from "react"

export default function Contact() {
const [email, setEmail] = useState('')
const handleSubmit = async (e: { preventDefault: () => void }) => {
e.preventDefault()

await fetch('/api/contact', {
method: 'Post',
body: JSON.stringify({ email }),
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
})
console.log('hey')
}


return <div>

<form onSubmit={handleSubmit}>
<input type="email" required value={email} onChange={(e)=> setEmail(e.target.value)}/>
<button type = 'submit'>submit</button>

</form>
</div>
}
2 changes: 2 additions & 0 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import '../styles/global.css'

export default function RootLayout({
children,
}: {
Expand Down
15 changes: 13 additions & 2 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@

import Link from 'next/link'
import styles from '../styles/home.module.css'

export default async function Home() {
return <div>hello</div>
return <div className={styles.home}>
<div>
<div> <h1>Hi, My name is Manel </h1></div>
<div>
<Link href= "/blog">Check my blog</Link>
</div>
<div>
<Link href="/contact"> Contact me </Link>
</div>
</div>
</div>
}
19 changes: 19 additions & 0 deletions lib/cms.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
const delay = (time: number | undefined) => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(1)
}, time)
})
}

export const getAllPosts = async () => {
await delay(3000)

return new Array(10).fill(1).map((_, i) => {
return {
title: `This is post ${i}`,
slug: `this-is-post-${i}`,
body:' tiruri tirura'
}
})
}
9 changes: 9 additions & 0 deletions pages/api/contact.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export default function handler(req, res) {
//save to DB

console.log(req.body)

if (req.method === 'POST') {
res.json({message:"ok"})
}
}
9 changes: 8 additions & 1 deletion styles/global.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
body, html {
margin: 0px;
padding: 0px;

}


* {
box-sizing: border-box;
}
}
9 changes: 9 additions & 0 deletions styles/home.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.home{
height: 100vh;
width: 100vw;
background: black;
color: white;
display: flex;
justify-content: center;
align-items: center;
}