File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ DATABASE_URL = " file:./dev.db"
2+ ANALYTICS_URL = " prathamesh.dhande"
3+ NEXT_PUBLIC_ANALYTICS_URL = " prathamesh.ananlytics"
Original file line number Diff line number Diff line change @@ -30,8 +30,6 @@ yarn-debug.log*
3030yarn-error.log *
3131.pnpm-debug.log *
3232
33- # env files (can opt-in for committing if needed)
34- .env *
3533
3634# vercel
3735.vercel
Original file line number Diff line number Diff line change @@ -2,7 +2,8 @@ import type { NextConfig } from "next";
22
33const nextConfig : NextConfig = {
44 /* config options here */
5- reactCompiler : true
5+ reactCompiler : true ,
6+ cacheComponents : true ,
67} ;
78
89export default nextConfig ;
Original file line number Diff line number Diff line change 1- import ArticleCard from "@/components/ArticleCard " ;
1+ import dynamic from "next/dynamic " ;
22
33// creating the type safety for the the Article Search Params
44interface ArticleDetailsPageProps {
55 params : Promise < { articleId : string } > ;
66 searchParams : Promise < { lang : "en" | "es" | "fr" } > ;
77}
88
9+ // Dynamic import component or lazy load the component
10+ const ArticleCard = dynamic ( ( ) => import ( "@/components/ArticleCard" ) ) ;
11+
912const ArticleDetailsPage = async ( {
1013 params,
1114 searchParams,
Original file line number Diff line number Diff line change 1- import { Metadata } from "next" ;
1+ import { Metadata , Viewport } from "next" ;
2+ import Image from "next/image" ;
3+ import BlogImage from "@/assets/images.jpg" ;
24
35// defining the title to override the parent title template
46export const metadata : Metadata = {
@@ -7,11 +9,19 @@ export const metadata: Metadata = {
79 } ,
810} ;
911
12+ // defining the viewport
13+ export const viewport : Viewport = {
14+ colorScheme : "dark" ,
15+ } ;
16+
1017export default function Blog ( ) {
1118 return (
1219 < div >
1320 < h1 > Blog</ h1 >
1421 < p > Welcome to the blog page!</ p >
22+
23+ { /* Using the nextjs Image Component */ }
24+ < Image src = { BlogImage } alt = "Blog image" > </ Image >
1525 </ div >
1626 ) ;
1727}
Original file line number Diff line number Diff line change 1+ export default async function Page ( ) {
2+ "use cache" ;
3+
4+ // Execute once, then cached for all requests
5+ const random = Math . random ( ) ;
6+ const random2 = Math . random ( ) ;
7+ const now = Date . now ( ) ;
8+ const date = new Date ( ) ;
9+ const uuid = crypto . randomUUID ( ) ;
10+ const bytes = crypto . getRandomValues ( new Uint8Array ( 16 ) ) ;
11+
12+ return (
13+ < div >
14+ < p >
15+ { random } and { random2 }
16+ </ p >
17+ < p > { now } </ p >
18+ < p > { date . getTime ( ) } </ p >
19+ < p > { uuid } </ p >
20+ < p > { bytes } </ p >
21+ </ div >
22+ ) ;
23+ }
Original file line number Diff line number Diff line change @@ -12,6 +12,8 @@ export async function GET(request: NextRequest) {
1212 headers : {
1313 "x-query" : String ( query ) ,
1414 "X-Powered-By" : "Prathamesh Dhande" ,
15+ // Using the Env values in the NextJS
16+ Analyticcs : String ( process . env . ANALYTICS_URL ) ,
1517 } ,
1618 } ) ;
1719}
Original file line number Diff line number Diff line change 11import { deleteProduct } from "@/actions/product" ;
22import { prisma } from "@/prisma.client" ;
3+ import { cacheLife } from "next/cache" ;
34import Form from "next/form" ;
45import Link from "next/link" ;
56
67const DBFetch = async ( ) => {
8+ // caching these content
9+ "use cache" ;
10+ cacheLife ( {
11+ stale : 60 ,
12+ revalidate : 60 ,
13+ expire : 60 ,
14+ } ) ;
715 // Accessing the DB prisma client on the server side page only
816 const products = await prisma . product . findMany ( {
917 orderBy : {
Original file line number Diff line number Diff line change @@ -17,6 +17,8 @@ const FetcherPage = () => {
1717 } ) ;
1818 return (
1919 < div >
20+ { /* Using the Browser based ENV value */ }
21+ { process . env . NEXT_PUBLIC_ANALYTICS_URL }
2022 < div >
2123 { isLoading ? (
2224 < div > Loading...</ div >
Original file line number Diff line number Diff line change @@ -3,6 +3,9 @@ import "./globals.css";
33import Footer from "@/components/Footer" ;
44import Header from "@/components/Header" ;
55import Provider from "@/components/Provider" ;
6+ import { Suspense } from "react" ;
7+ // Importing the font with its font name
8+ import { Edu_NSW_ACT_Cursive } from "next/font/google" ;
69
710// Title metadata configuring title to be used by the child routes also
811export const metadata : Metadata = {
@@ -15,19 +18,29 @@ export const metadata: Metadata = {
1518 "A simple NextJS tutorial to get started with NextJS 13 and the new app directory structure." ,
1619} ;
1720
21+ // Declaring the Font
22+ const cursivefont = Edu_NSW_ACT_Cursive ( {
23+ subsets : [ "latin" ] ,
24+ } ) ;
25+
1826export default function RootLayout ( {
1927 children,
2028} : Readonly < {
2129 children : React . ReactNode ;
2230} > ) {
2331 return (
24- < html lang = "en" >
32+ // add to include as the classname
33+ < html lang = "en" className = { cursivefont . className } >
2534 < body >
26- < Header > </ Header >
35+ < Suspense fallback = { < div > Loading...</ div > } >
36+ < Header > </ Header >
37+ </ Suspense >
2738 { /* Pass the Context Provider or any client side provider in these way */ }
28- < Provider >
29- < main > { children } </ main >
30- </ Provider >
39+ < Suspense fallback = { < div > Loading....</ div > } >
40+ < Provider >
41+ < main > { children } </ main >
42+ </ Provider >
43+ </ Suspense >
3144 < Footer />
3245 </ body >
3346 </ html >
You can’t perform that action at this time.
0 commit comments