Skip to content

Commit 27f9d47

Browse files
clean up repo including formatting
1 parent 2fd0c04 commit 27f9d47

File tree

17 files changed

+11664
-7858
lines changed

17 files changed

+11664
-7858
lines changed

.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next/core-web-vitals", "prettier"]
3+
}

app/actions.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
'use server'
1+
'use server';
22

33
import('harperdb');
44

@@ -12,4 +12,4 @@ export async function listDogs() {
1212

1313
export async function getDog(id) {
1414
return tables.Dog.get(id);
15-
}
15+
}

app/api/ethans-favorite-dog/route.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

app/api/route.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/client-component.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1-
'use client'
1+
'use client';
22

3-
import { useEffect, useState } from "react";
4-
import { listDogs } from "@/app/actions"
3+
import { useEffect, useState } from 'react';
4+
import { listDogs } from '@/app/actions';
55

6-
export default function ClientComponent () {
6+
export default function ClientComponent() {
77
const [dogs, setDogs] = useState([]);
8-
8+
99
useEffect(() => {
10-
listDogs().then(dogs => setDogs(dogs));
10+
listDogs().then((dogs) => setDogs(dogs));
1111
}, []);
1212

1313
return (
14-
<p>I'm a Client Component. There are <strong>{dogs.length}</strong> dogs in the Dog table.</p>
15-
)
16-
}
14+
<p>
15+
I&apos;m a Client Component. There are <strong>{dogs.length}</strong> dogs in the Dog table.
16+
</p>
17+
);
18+
}

app/dogs/[id]/page.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getDog, listDogs } from "@/app/actions";
1+
import { getDog, listDogs } from '@/app/actions';
22

33
export async function generateStaticParams() {
44
const dogs = await listDogs();
@@ -7,7 +7,6 @@ export async function generateStaticParams() {
77
}
88

99
export default async function Dog({ params }) {
10-
1110
const dog = await getDog(params.id);
1211

1312
return (
@@ -16,5 +15,5 @@ export default async function Dog({ params }) {
1615
<p>Breed: {dog.get('breed')}</p>
1716
<p>Woof!</p>
1817
</section>
19-
)
20-
}
18+
);
19+
}

app/dogs/layout.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
1-
import Link from "next/link";
2-
import { listDogs } from "@/app/actions";
1+
import Link from 'next/link';
2+
import { listDogs } from '@/app/actions';
33

44
export default async function Dogs({ children }) {
5-
65
const dogs = await listDogs();
76

87
return (
98
<>
109
<section>
1110
<h2>Dogs</h2>
12-
<aside>This page is a Next.js Server Component employing Static Rendering. This is the default Next.js page experience. The list of dogs below was queried and the page was rendered all at <strong>build time</strong>.</aside>
13-
<p>Furthermore, this page has a subroute comprised of individual pages for each of the dogs. These pages were also generated at build time! Click on any dog in the list to see it's details.</p>
11+
<aside>
12+
This page is a Next.js Server Component employing Static Rendering. This is the default Next.js page
13+
experience. The list of dogs below was queried and the page was rendered all at <strong>build time</strong>.
14+
</aside>
15+
<p>
16+
Furthermore, this page has a subroute comprised of individual pages for each of the dogs. These pages were
17+
also generated at build time! Click on any dog in the list to see it&apos;s details.
18+
</p>
1419
<ol>
15-
{dogs.map(dog => (
16-
<li key={dog.id}><Link href={`/dogs/${dog.id}`}>{dog.name}</Link></li>
20+
{dogs.map((dog) => (
21+
<li key={dog.id}>
22+
<Link href={`/dogs/${dog.id}`}>{dog.name}</Link>
23+
</li>
1724
))}
1825
</ol>
1926
</section>
2027
{children}
2128
</>
22-
)
23-
}
29+
);
30+
}

app/dogs/page.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export default async function Page() {
2-
return <p>Select a dog!</p>
3-
}
2+
return <p>Select a dog!</p>;
3+
}

app/layout.js

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,40 @@
1-
import Link from "next/link"
1+
import Link from 'next/link';
22

33
export const metadata = {
4-
title: 'HarperDB - Next.js App',
5-
}
4+
title: 'HarperDB - Next.js App',
5+
};
66

77
export default function RootLayout({ children }) {
8-
return (
9-
<html lang="en">
10-
<body style={{ width: '500px', fontFamily: 'sans-serif' }}>
11-
<header>
12-
<nav>
13-
<ul style={{ display: 'flex', gap: '1rem', listStyle: 'none', padding: 0 }}>
14-
<li>
15-
<Link href="/">Home</Link>
16-
</li>
17-
<li>
18-
<Link href="/dogs">Dogs</Link>
19-
</li>
20-
</ul>
21-
</nav>
22-
</header>
23-
<main>
24-
<section style={{ borderBottom: '1px solid' }}>
25-
<h1>HarperDB Next.js Example Application</h1>
26-
<p>This application demonstrates multiple distinct Next.js features.</p>
8+
return (
9+
<html lang="en">
10+
<body style={{ width: '500px', fontFamily: 'sans-serif' }}>
11+
<header>
12+
<nav>
13+
<ul style={{ display: 'flex', gap: '1rem', listStyle: 'none', padding: 0 }}>
14+
<li>
15+
<Link href="/">Home</Link>
16+
</li>
17+
<li>
18+
<Link href="/dogs">Dogs</Link>
19+
</li>
20+
</ul>
21+
</nav>
22+
</header>
23+
<main>
24+
<section style={{ borderBottom: '1px solid' }}>
25+
<h1>HarperDB Next.js Example Application</h1>
26+
<p>This application demonstrates multiple distinct Next.js features.</p>
2727

28-
<p>Use the navigation links to try different page types.</p>
28+
<p>Use the navigation links to try different page types.</p>
2929

30-
<p>Dig into the source code here: <Link href="https://github.com/HarperDB-Add-Ons/nextjs-example">HarperDB-Add-Ons/nextjs-example</Link></p>
31-
</section>
32-
{children}
33-
</main>
34-
</body>
35-
</html>
36-
)
30+
<p>
31+
Dig into the source code here:{' '}
32+
<Link href="https://github.com/HarperDB-Add-Ons/nextjs-example">HarperDB-Add-Ons/nextjs-example</Link>
33+
</p>
34+
</section>
35+
{children}
36+
</main>
37+
</body>
38+
</html>
39+
);
3740
}

app/page.js

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
import Link from "next/link";
2-
import ClientComponent from "./client-component";
1+
import Link from 'next/link';
2+
import ClientComponent from './client-component';
33

44
export default async function Page() {
5-
return (
6-
<section>
7-
<ClientComponent/>
8-
<p>Check out the <Link href="/dogs">Dogs</Link> page to get started.</p>
9-
</section>
10-
)
11-
}
5+
return (
6+
<section>
7+
<ClientComponent />
8+
<p>
9+
Check out the <Link href="/dogs">Dogs</Link> page to get started.
10+
</p>
11+
</section>
12+
);
13+
}

0 commit comments

Comments
 (0)