Skip to content
This repository was archived by the owner on Oct 16, 2024. It is now read-only.

Commit 4d9c9e4

Browse files
committed
tested 'getServerSideProps()' (nextjs)
1 parent 808296b commit 4d9c9e4

File tree

24 files changed

+3615
-15
lines changed

24 files changed

+3615
-15
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": ["next", "next/core-web-vitals"]
3+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
27+
# local env files
28+
.env.local
29+
.env.development.local
30+
.env.test.local
31+
.env.production.local
32+
33+
# vercel
34+
.vercel
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
> Inspired by https://github.com/vercel/next.js/tree/canary/examples/with-redux
2+
3+
4+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
5+
6+
## Getting Started
7+
8+
First, run the development server:
9+
10+
```bash
11+
npm run dev
12+
# or
13+
yarn dev
14+
```
15+
16+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
17+
18+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
19+
20+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.tsx`.
21+
22+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
23+
24+
## Learn More
25+
26+
To learn more about Next.js, take a look at the following resources:
27+
28+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
29+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
30+
31+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
32+
33+
## Deploy on Vercel
34+
35+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
36+
37+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { useAgile } from '@agile-ts/react';
2+
import { LAST_UPDATED_TIMESTAMP, LIGHT } from '../src/core';
3+
4+
const formatTime = (timestamp: number) => {
5+
// cut off except hh:mm:ss
6+
return new Date(timestamp).toJSON().slice(11, 19);
7+
};
8+
9+
const Clock = () => {
10+
const [lastUpdatedTimestamp, light] = useAgile([
11+
LAST_UPDATED_TIMESTAMP,
12+
LIGHT,
13+
]);
14+
15+
return (
16+
<div className={light ? 'light' : ''}>
17+
{formatTime(lastUpdatedTimestamp)}
18+
<style jsx>{`
19+
div {
20+
padding: 15px;
21+
display: inline-block;
22+
color: #82fa58;
23+
font: 50px menlo, monaco, monospace;
24+
background-color: #000;
25+
}
26+
.light {
27+
background-color: #999;
28+
}
29+
`}</style>
30+
</div>
31+
);
32+
};
33+
34+
export default Clock;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { useAgile } from '@agile-ts/react';
2+
import {
3+
COUNTER,
4+
decrementCount,
5+
incrementCount,
6+
resetCount,
7+
} from '../src/core';
8+
9+
const Counter = () => {
10+
const count = useAgile(COUNTER);
11+
12+
return (
13+
<div>
14+
<h1>
15+
Count: <span>{count}</span>
16+
</h1>
17+
<button onClick={incrementCount}>+1</button>
18+
<button onClick={decrementCount}>-1</button>
19+
<button onClick={resetCount}>Reset</button>
20+
</div>
21+
);
22+
};
23+
24+
export default Counter;
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import Link from 'next/link';
2+
3+
const Nav = () => {
4+
return (
5+
<nav>
6+
<Link href="/">
7+
<a>Index</a>
8+
</Link>
9+
<Link href="/ssg">
10+
<a>SSG</a>
11+
</Link>
12+
<Link href="/ssr">
13+
<a>SSR</a>
14+
</Link>
15+
<style jsx>
16+
{`
17+
a {
18+
margin-right: 25px;
19+
}
20+
`}
21+
</style>
22+
</nav>
23+
);
24+
};
25+
26+
export default Nav;
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import useInterval from '../src/useInterval';
2+
import Nav from './Nav';
3+
import Clock from './Clock';
4+
import Counter from './Counter';
5+
import { tick } from '../src/core';
6+
7+
const Page = () => {
8+
// Tick the time every second
9+
useInterval(() => {
10+
tick(Date.now(), true);
11+
}, 1000);
12+
13+
return (
14+
<>
15+
<Nav />
16+
<Clock />
17+
<Counter />
18+
</>
19+
);
20+
};
21+
22+
export default Page;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/types/global" />
3+
/// <reference types="next/image-types/global" />
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
reactStrictMode: true,
3+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "clock",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint",
10+
"install:dev:agile": "yalc add @agile-ts/core @agile-ts/react @agile-ts/logger @agile-ts/utils & yarn install",
11+
"install:prod:agile": "yarn add @agile-ts/core @agile-ts/react @agile-ts/logger @agile-ts/utils & yarn install"
12+
},
13+
"dependencies": {
14+
"@agile-ts/core": "file:.yalc/@agile-ts/core",
15+
"@agile-ts/logger": "file:.yalc/@agile-ts/logger",
16+
"@agile-ts/react": "file:.yalc/@agile-ts/react",
17+
"@agile-ts/utils": "file:.yalc/@agile-ts/utils",
18+
"next": "11.0.1",
19+
"react": "17.0.2",
20+
"react-dom": "17.0.2"
21+
},
22+
"devDependencies": {
23+
"@types/react": "17.0.14",
24+
"eslint": "7.31.0",
25+
"eslint-config-next": "11.0.1",
26+
"typescript": "4.3.5"
27+
}
28+
}

0 commit comments

Comments
 (0)