forked from vercel/nextgram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use app router with interception (vercel#4)
* Link codemod * Image codemod * Use pnpm * Upgrade Next.js and React * Use app router with interception
- Loading branch information
1 parent
cfe4b1e
commit f3cc917
Showing
18 changed files
with
492 additions
and
1,056 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/.next | ||
/node_modules | ||
.vercel |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import Photo from "../../../../components/frame"; | ||
import Modal from "../../../../components/modal"; | ||
import swagPhotos from "../../../../photos"; | ||
|
||
export default function PhotoModal({ params: { id: photoId } }) { | ||
const photos = swagPhotos; | ||
const photo = photoId && photos.find((p) => p.id === photoId); | ||
|
||
return ( | ||
<Modal> | ||
<Photo photo={photo} /> | ||
</Modal> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Default() { | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default function Default() { | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import "../styles/reboot.css"; | ||
|
||
export default function Layout(props) { | ||
return ( | ||
<html> | ||
<body> | ||
{props.children} | ||
{props.modal} | ||
</body> | ||
</html> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import Link from "next/link"; | ||
import styles from "../styles/home.module.scss"; | ||
import swagPhotos from "../photos"; | ||
import BlurImage from "../components/BlurImage"; | ||
|
||
export default function Home() { | ||
const photos = swagPhotos; | ||
|
||
return ( | ||
<main className={styles.container}> | ||
<div> | ||
<h1>NextGram</h1> | ||
</div> | ||
<div className={styles.images}> | ||
{photos.map(({ id, imageSrc }) => ( | ||
<div key={id} className={styles.imageContainer}> | ||
<div key={id} className={styles.imageWrapper}> | ||
<Link href={`/photos/${id}`}> | ||
<BlurImage | ||
alt="" | ||
src={imageSrc} | ||
height={500} | ||
width={500} | ||
objectFit="cover" | ||
/> | ||
</Link> | ||
</div> | ||
</div> | ||
))} | ||
</div> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from "react"; | ||
import Photo from "../../../components/frame"; | ||
import swagPhotos from "../../../photos"; | ||
import { permalink, wrap } from "./styles.module.css"; | ||
|
||
export default function PhotoPage({ params: { id } }) { | ||
const photo = swagPhotos.find((p) => p.id === id); | ||
|
||
return ( | ||
<div className={permalink}> | ||
<div className={wrap}> | ||
<Photo photo={photo} /> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.permalink { | ||
padding: 100px; | ||
text-align: center; | ||
} | ||
|
||
.wrap { | ||
display: inline-block; | ||
border: 1px solid #999; | ||
margin: auto; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,16 @@ | ||
import Image from "next/image"; | ||
"use client"; | ||
import Image from "next/legacy/image"; | ||
import styles from "./styles.module.css"; | ||
import { useState } from "react"; | ||
import cn from "clsx"; | ||
|
||
export default function BlurImage(props) { | ||
const [isLoading, setLoading] = useState(true); | ||
// const [isLoading, setLoading] = useState(true); | ||
return ( | ||
<Image | ||
{...props} | ||
className={cn( | ||
styles["image-transition"], | ||
isLoading ? styles["image-loading"] : styles["image-loaded"] | ||
)} | ||
onLoadingComplete={() => setLoading(false)} | ||
className={cn(styles["image-transition"], styles["image-loaded"])} | ||
// onLoadingComplete={() => setLoading(false)} | ||
/> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
module.exports = { | ||
reactStrictMode: true, | ||
images: { | ||
domains: ['pbs.twimg.com'], | ||
domains: ["pbs.twimg.com"], | ||
}, | ||
experimental: { | ||
appDir: true, | ||
}, | ||
}; |
Oops, something went wrong.