Skip to content

Commit

Permalink
second
Browse files Browse the repository at this point in the history
  • Loading branch information
larbi-ishak committed Jul 19, 2023
1 parent 015635c commit 14b7654
Show file tree
Hide file tree
Showing 34 changed files with 6,698 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "next/core-web-vitals"
}
1 change: 1 addition & 0 deletions .gitgnore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules
34 changes: 34 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# local env files
.env*.local

# vercel
.vercel

secretfile.json
7 changes: 7 additions & 0 deletions data/dashboard.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dashboard": {
"likes": "900K",
"followers": "200k",
"posts": 130
}
}
19 changes: 19 additions & 0 deletions data/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"posts": [
{
"id": 1,
"title": "json-server",
"author": "typicode"
}
],
"comments": [
{
"id": 1,
"body": "some comment",
"postId": 1
}
],
"profile": {
"name": "typicode"
}
}
104 changes: 104 additions & 0 deletions data/products.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
{
"products": [
{
"id": 1,
"title": "title 1",
"desc": "description 1",
"category": "youth",
"date": "12-03-2013",
"price": 10
},
{
"id": 2,
"title": "title 2",
"desc": "description 1",
"category": "sport",
"date": "12-03-2013",
"price": 20
},
{
"id": 3,
"title": "title 3",
"desc": "description 1",
"category": "sport",
"date": "12-03-2013",
"price": 30
},
{
"id": 4,
"title": "title 4",
"desc": "description 1",
"category": "sport",
"date": "12-03-2013",
"price": 40
},
{
"id": 5,
"title": "title 5",
"desc": "description 1",
"category": "war",
"date": "12-03-2013",
"price": 50
},
{
"id": 6,
"title": "title 6",
"desc": "description 1",
"category": "war",
"date": "12-03-2013",
"price": 60
},
{
"id": 7,
"title": "title 7",
"desc": "description 1",
"category": "war",
"date": "12-03-2013",
"price": 70
},
{
"id": 8,
"title": "title 8",
"desc": "description 1",
"category": "health",
"date": "12-03-2013",
"price": 80
},
{
"id": 9,
"title": "title 9",
"desc": "description 1",
"category": "politic",
"date": "12-03-2013",
"price": 90
},
{
"id": 10,
"title": "title 10",
"desc": "description 1",
"category": "politic",
"date": "12-03-2013",
"price": 100
}
],
"blogs": [
{
"title": "Blog title",
"publish date": "01-01-1970",
"content": "Lorem ipsum dolor sit amet, ",
"category": "beauty"
},
{
"title": "Blog title 2",
"publish date": "01-01-1970",
"content": "Lorem ipsum dolor sit amet, ",
"category": "health"
},
{
"title": "Blog title 3",
"publish date": "01-01-1970",
"content": "Lorem ipsum dolor sit amet, ",
"category": "beauty"
}
]
}
19 changes: 19 additions & 0 deletions db-1676975524439.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"products": [
{
"id": 1,
"title": "prod 1",
"description": "prod1 desc"
},
{
"id": 2,
"title": "prod 2",
"description": "prod2 desc"
},
{
"id": 3,
"title": "prod 3",
"description": "prod3 desc"
}
]
}
8 changes: 8 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
}
}
33 changes: 33 additions & 0 deletions learned.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
big issues of SSG: stale data large build time when pages are big , 100000 pages takes an hour to build

ISR:
updating statically generated pages without rebuilding, with revalidate option

in getStaticProps() we return revalidate
return {
props: {
data,
},
revalidate: 10, seconds
};


nextJs serves the client with cache html page
when user send request it responses with the cache
when revalidating after the delay (10 seconds) here the cache will be replaced so , the page still stale until we make another request

in SSG:
we don't have access to the user request in Real Time

SSR: pre-rendering
is used only when needed , it's resource consuming and slower than SSG or ISR, (fits in large projects)
SSR is allowed only in a page , not allowed in a component
getServerSideProps should return object containing Props
we can set cookies by accessing the res: we can use them to do operations on token , authentication

Client Side data fetching:
SEO is Irrelevant
so when building user specific , SEO Irrelevant pages, like profiles, dashboards you better do Client side fetching
SWR is recommended for Client side fetching

swr auto updates the data fetched when changed
5 changes: 5 additions & 0 deletions next-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/// <reference types="next" />
/// <reference types="next/image-types/global" />

// NOTE: This file should not be edited
// see https://nextjs.org/docs/basic-features/typescript for more information.
5 changes: 5 additions & 0 deletions next.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
};
module.exports = nextConfig;
Loading

0 comments on commit 14b7654

Please sign in to comment.