-
Notifications
You must be signed in to change notification settings - Fork 27k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'canary' of github.com:zeit/next.js into native-url
- Loading branch information
Showing
459 changed files
with
7,099 additions
and
2,861 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
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,4 +1,5 @@ | ||
node_modules | ||
**/.next/** | ||
**/_next/** | ||
**/dist/** | ||
**/dist/** | ||
packages/next/compiled/** |
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,3 +1,4 @@ | ||
**/.next/** | ||
**/_next/** | ||
**/dist/** | ||
**/dist/** | ||
packages/next/compiled/**/* |
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 @@ | ||
#!/bin/bash | ||
|
||
yarn --cwd packages/next ncc-compiled | ||
|
||
# Make sure to exit with 1 if there are changes after running ncc-compiled | ||
# step to ensure we get any changes committed | ||
|
||
if [[ ! -z $(git status -s) ]];then | ||
echo "Detected changes" | ||
git status | ||
exit 1 | ||
fi |
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
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
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
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
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,27 +1,29 @@ | ||
import fetch from 'isomorphic-unfetch' | ||
import useSWR from 'swr' | ||
|
||
const Index = ({ users }) => ( | ||
<div> | ||
{users.map((user, i) => ( | ||
<div key={i}>{user.name}</div> | ||
))} | ||
</div> | ||
) | ||
|
||
Index.getInitialProps = async () => { | ||
const response = await fetch('http://localhost:3000/api/graphql', { | ||
const fetcher = query => | ||
fetch('/api/graphql', { | ||
method: 'POST', | ||
headers: { | ||
'Content-type': 'application/json', | ||
}, | ||
body: JSON.stringify({ query: '{ users { name } }' }), | ||
body: JSON.stringify({ query }), | ||
}) | ||
.then(res => res.json()) | ||
.then(json => json.data) | ||
|
||
const { | ||
data: { users }, | ||
} = await response.json() | ||
export default function Index() { | ||
const { data, error } = useSWR('{ users { name } }', fetcher) | ||
|
||
return { users } | ||
} | ||
if (error) return <div>Failed to load</div> | ||
if (!data) return <div>Loading...</div> | ||
|
||
export default Index | ||
const { users } = data | ||
|
||
return ( | ||
<div> | ||
{users.map((user, i) => ( | ||
<div key={i}>{user.name}</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
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,8 +1,10 @@ | ||
import cookies from '../../utils/cookies' | ||
|
||
const handler = (req, res) => { | ||
// The cookie middleware will add the `set-cookie` header | ||
res.cookie('Next.js', 'api-middleware!') | ||
res.end('Hello Next.js middleware!') | ||
// Return the `set-cookie` header so we can display it in the browser and show that it works! | ||
res.end(res.getHeader('Set-Cookie')) | ||
} | ||
|
||
export default cookies(handler) |
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,12 +1,12 @@ | ||
import fetch from 'isomorphic-unfetch' | ||
import useSWR from 'swr' | ||
|
||
const Index = ({ cookie }) => <div>{`Cookie from response: ${cookie}`}</div> | ||
const fetcher = url => fetch(url).then(res => res.text()) | ||
|
||
export async function getServerSideProps() { | ||
const response = await fetch('http://localhost:3000/api/cookies') | ||
const cookie = response.headers.get('set-cookie') | ||
export default function Index() { | ||
const { data, error } = useSWR('/api/cookies', fetcher) | ||
|
||
return { props: { cookie } } | ||
} | ||
if (error) return <div>Failed to load</div> | ||
if (!data) return <div>Loading...</div> | ||
|
||
export default Index | ||
return <div>{`Cookie from response: "${data}"`}</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
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,19 +1,19 @@ | ||
import useSWR from 'swr' | ||
import Person from '../components/Person' | ||
import fetch from 'node-fetch' | ||
|
||
const Index = ({ people }) => ( | ||
<ul> | ||
{people.map((p, i) => ( | ||
<Person key={i} person={p} /> | ||
))} | ||
</ul> | ||
) | ||
const fetcher = url => fetch(url).then(res => res.json()) | ||
|
||
export async function getServerSideProps() { | ||
const response = await fetch('http://localhost:3000/api/people') | ||
const people = await response.json() | ||
export default function Index() { | ||
const { data, error } = useSWR('/api/people', fetcher) | ||
|
||
return { props: { people } } | ||
} | ||
if (error) return <div>Failed to load</div> | ||
if (!data) return <div>Loading...</div> | ||
|
||
export default Index | ||
return ( | ||
<ul> | ||
{data.map((p, i) => ( | ||
<Person key={i} person={p} /> | ||
))} | ||
</ul> | ||
) | ||
} |
Oops, something went wrong.