Skip to content

Commit d114d26

Browse files
committed
chore: add demo
1 parent df0f29e commit d114d26

16 files changed

+292
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ If you are using `next export` to generate a static site, you do not need most o
8282
you can remove it. Alternatively you can
8383
[set the environment variable](https://docs.netlify.com/configure-builds/environment-variables/)
8484
`NETLIFY_NEXT_PLUGIN_SKIP` to `true` and the plugin will handle caching but won't generate any functions for SSR
85-
support.
85+
support. See [`demos/next-export`](https://github.com/netlify/netlify-plugin-nextjs/tree/main/demos/next-export) for an
86+
example.
8687

8788
## Feedback
8889

demos/next-export/.eslintrc

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"extends": "next",
3+
"root": true
4+
}

demos/next-export/.gitignore

+34
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

demos/next-export/README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
This is an example of a site that uses `next export`. It only uses the plugin for cache handling and sets
2+
`NETLIFY_NEXT_PLUGIN_SKIP` to disable everything else.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require('../../../lib')
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
name: '@netlify/plugin-nextjs-local'

demos/next-export/local-plugin/package-lock.json

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "local-plugin",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"preinstall": "cd ../../.. && npm i"
8+
},
9+
"author": "",
10+
"license": "ISC"
11+
}

demos/next-export/netlify.toml

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[build]
2+
command = "next build && next export"
3+
publish = "out"
4+
ignore = "git diff --quiet $CACHED_COMMIT_REF $COMMIT_REF ../../"
5+
6+
[build.environment]
7+
NETLIFY_NEXT_PLUGIN_SKIP = "true"
8+
9+
[dev]
10+
framework = "#static"
11+
12+
[[plugins]]
13+
package = "./local-plugin"
14+
15+
[[plugins]]
16+
package = "@netlify/plugin-local-install-core"

demos/next-export/next.config.js

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
// Configurable site features we support:
3+
// distDir: 'build',
4+
generateBuildId: () => 'build-id',
5+
}

demos/next-export/pages/_app.js

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import '../styles/globals.css'
2+
3+
function MyApp({ Component, pageProps }) {
4+
return <Component {...pageProps} />
5+
}
6+
7+
export default MyApp

demos/next-export/pages/another.js

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import Head from 'next/head'
2+
import { useRouter } from 'next/router'
3+
import styles from '../styles/Home.module.css'
4+
5+
export default function Home() {
6+
const { locale } = useRouter()
7+
return (
8+
<div className={styles.container}>
9+
<Head>
10+
<title>Create Next App</title>
11+
<meta name="description" content="Generated by create next app" />
12+
<link rel="icon" href="/favicon.ico" />
13+
</Head>
14+
15+
<main className={styles.main}>
16+
<h1 className={styles.title}>Another page</h1>
17+
</main>
18+
19+
20+
</div>
21+
)
22+
}

demos/next-export/pages/index.js

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import Head from 'next/head'
2+
import { useRouter } from 'next/router'
3+
import styles from '../styles/Home.module.css'
4+
5+
export default function Home() {
6+
const { locale } = useRouter()
7+
return (
8+
<div className={styles.container}>
9+
<Head>
10+
<title>Create Next App</title>
11+
<meta name="description" content="Generated by create next app" />
12+
<link rel="icon" href="/favicon.ico" />
13+
</Head>
14+
15+
<main className={styles.main}>
16+
<h1 className={styles.title}>
17+
Welcome to <a href="https://nextjs.org">Next.js!</a>
18+
</h1>
19+
20+
<p>The current locale is {locale}</p>
21+
22+
<p className={styles.description}>
23+
Get started by editing <code className={styles.code}>pages/index.js</code>
24+
</p>
25+
26+
<div className={styles.grid}>
27+
<a href="https://nextjs.org/docs" className={styles.card}>
28+
<h2>Documentation &rarr;</h2>
29+
<p>Find in-depth information about Next.js features and API.</p>
30+
</a>
31+
32+
<a href="https://nextjs.org/learn" className={styles.card}>
33+
<h2>Learn &rarr;</h2>
34+
<p>Learn about Next.js in an interactive course with quizzes!</p>
35+
</a>
36+
37+
<a href="https://github.com/vercel/next.js/tree/master/examples" className={styles.card}>
38+
<h2>Examples &rarr;</h2>
39+
<p>Discover and deploy boilerplate example Next.js projects.</p>
40+
</a>
41+
</div>
42+
</main>
43+
</div>
44+
)
45+
}

demos/next-export/public/favicon.ico

14.7 KB
Binary file not shown.
+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
.container {
2+
min-height: 100vh;
3+
padding: 0 0.5rem;
4+
display: flex;
5+
flex-direction: column;
6+
justify-content: center;
7+
align-items: center;
8+
height: 100vh;
9+
}
10+
11+
.main {
12+
padding: 5rem 0;
13+
flex: 1;
14+
display: flex;
15+
flex-direction: column;
16+
justify-content: center;
17+
align-items: center;
18+
}
19+
20+
.footer {
21+
width: 100%;
22+
height: 100px;
23+
border-top: 1px solid #eaeaea;
24+
display: flex;
25+
justify-content: center;
26+
align-items: center;
27+
}
28+
29+
.footer a {
30+
display: flex;
31+
justify-content: center;
32+
align-items: center;
33+
flex-grow: 1;
34+
}
35+
36+
.title a {
37+
color: #0070f3;
38+
text-decoration: none;
39+
}
40+
41+
.title a:hover,
42+
.title a:focus,
43+
.title a:active {
44+
text-decoration: underline;
45+
}
46+
47+
.title {
48+
margin: 0;
49+
line-height: 1.15;
50+
font-size: 4rem;
51+
}
52+
53+
.title,
54+
.description {
55+
text-align: center;
56+
}
57+
58+
.description {
59+
line-height: 1.5;
60+
font-size: 1.5rem;
61+
}
62+
63+
.code {
64+
background: #fafafa;
65+
border-radius: 5px;
66+
padding: 0.75rem;
67+
font-size: 1.1rem;
68+
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
69+
Bitstream Vera Sans Mono, Courier New, monospace;
70+
}
71+
72+
.grid {
73+
display: flex;
74+
align-items: center;
75+
justify-content: center;
76+
flex-wrap: wrap;
77+
max-width: 800px;
78+
margin-top: 3rem;
79+
}
80+
81+
.card {
82+
margin: 1rem;
83+
padding: 1.5rem;
84+
text-align: left;
85+
color: inherit;
86+
text-decoration: none;
87+
border: 1px solid #eaeaea;
88+
border-radius: 10px;
89+
transition: color 0.15s ease, border-color 0.15s ease;
90+
width: 45%;
91+
}
92+
93+
.card:hover,
94+
.card:focus,
95+
.card:active {
96+
color: #0070f3;
97+
border-color: #0070f3;
98+
}
99+
100+
.card h2 {
101+
margin: 0 0 1rem 0;
102+
font-size: 1.5rem;
103+
}
104+
105+
.card p {
106+
margin: 0;
107+
font-size: 1.25rem;
108+
line-height: 1.5;
109+
}
110+
111+
.logo {
112+
height: 1em;
113+
margin-left: 0.5rem;
114+
}
115+
116+
@media (max-width: 600px) {
117+
.grid {
118+
width: 100%;
119+
flex-direction: column;
120+
}
121+
}

demos/next-export/styles/globals.css

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
html,
2+
body {
3+
padding: 0;
4+
margin: 0;
5+
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen,
6+
Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
7+
}
8+
9+
a {
10+
color: inherit;
11+
text-decoration: none;
12+
}
13+
14+
* {
15+
box-sizing: border-box;
16+
}

0 commit comments

Comments
 (0)