Add Next.js frontend
This commit is contained in:
12
reactNextJS/app/layout.js
Normal file
12
reactNextJS/app/layout.js
Normal file
@@ -0,0 +1,12 @@
|
||||
export const metadata = {
|
||||
title: 'Next.js',
|
||||
description: 'Generated by Next.js',
|
||||
}
|
||||
|
||||
export default function RootLayout({ children }) {
|
||||
return (
|
||||
<html lang="en">
|
||||
<body>{children}</body>
|
||||
</html>
|
||||
)
|
||||
}
|
||||
29
reactNextJS/app/page.js
Normal file
29
reactNextJS/app/page.js
Normal file
@@ -0,0 +1,29 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
|
||||
const blurb_data = {
|
||||
title: "Fart Man Comes To Town!",
|
||||
blurb: "Will this controversial figure finally cause the downfall of the town? Sally Smith from town center says that she can already smell trouble brewing but other members of the town believe the imminent winds of change will revitalize the towns central business district."
|
||||
};
|
||||
|
||||
function Blurb({ title, blurb }) {
|
||||
return (<div>
|
||||
<h1>{ title }</h1>
|
||||
<p>{ blurb }</p>
|
||||
<a href="#">Read more...</a>
|
||||
</div>);
|
||||
}
|
||||
|
||||
export default function HomePage() {
|
||||
const [blurbs, setBlurbs] = useState([ blurb_data ])
|
||||
function addBlurb() {
|
||||
setBlurbs(blurbs.concat([blurb_data]));
|
||||
}
|
||||
return (<>
|
||||
{blurbs.map((blurb, i) => (
|
||||
<Blurb key={i} {...blurb} />
|
||||
))}
|
||||
<br />
|
||||
<button onClick={addBlurb}>Load More</button>
|
||||
</>);
|
||||
}
|
||||
Reference in New Issue
Block a user