Skip to content

Commit

Permalink
Merge branch 'canary' into with-tailwindcss-emotion
Browse files Browse the repository at this point in the history
  • Loading branch information
heyfirst authored Oct 14, 2019
2 parents 7301fd7 + 09681cd commit a8cb017
Show file tree
Hide file tree
Showing 332 changed files with 2,344 additions and 1,328 deletions.
8 changes: 4 additions & 4 deletions README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export default () => <div>Welcome to next.js!</div>
- 自动打包编译 (使用 webpack 和 babel)
- 热加载
-`./pages`作为服务的渲染和索引
- 静态文件服务. `./static/` 映射到 `/static/` (可以 [创建一个静态目录](#static-file-serving-eg-images) 在你的项目中)
- 静态文件服务. `./public/` 映射到 `/` (可以 [创建一个静态目录](#static-file-serving-eg-images) 在你的项目中)

这里有个简单的案例,可以下载看看 [sample app - nextgram](https://github.com/zeit/nextgram)

Expand Down Expand Up @@ -227,13 +227,13 @@ export default () => <p style={{ color: 'red' }}>hi there</p>

### 静态文件服务(如图像)

在根目录下新建文件夹叫`static`。代码可以通过`/static/`来引入相关的静态资源。
在根目录下新建文件夹叫`public`。代码可以通过`/`来引入相关的静态资源。

```jsx
export default () => <img src="/static/my-image.png" alt="my image" />
export default () => <img src="/my-image.png" alt="my image" />
```

_注意:不要自定义静态文件夹的名字,只能叫`static` ,因为只有这个名字 Next.js 才会把它当作静态资源。_
_注意:不要自定义静态文件夹的名字,只能叫`public` ,因为只有这个名字 Next.js 才会把它当作静态资源。_

<a id="populating-head" style="display: none"></a>

Expand Down
2 changes: 1 addition & 1 deletion contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Our Commitment to Open Source can be found [here](https://zeit.co/blog/oss)
3. Install the dependencies: `yarn`
4. Run `yarn dev` to build and watch for code changes
5. In a new terminal, run `yarn types` to compile declaration files from TypeScript
6. The development branch is `canary`. On a release, the relevant parts of the changes in the `canary` branch are rebased into `master`.
6. The development branch is `canary` (this is the branch pull requests should be made against). On a release, the relevant parts of the changes in the `canary` branch are rebased into `master`.

> You may need to run `yarn types` again if your types get outdated.
Expand Down
15 changes: 15 additions & 0 deletions errors/can-not-output-to-public.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Cannot output to /public

#### Why This Error Occurred

Either you set `distDir` to `public` in your `next.config.js` or during `next export` you tried to export to the `public` directory.

This is not allowed due to `public` being a special folder in Next.js used to serve static assets.

#### Possible Ways to Fix It

Use a different `distDir` or export to a different folder.

### Useful Links

- [Static file serving docs](https://nextjs.org/docs#static-file-serving-eg-images)
11 changes: 11 additions & 0 deletions errors/global-css.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Global CSS Must Be in Your Custom <App>

#### Why This Error Occurred

An attempt to import Global CSS from a file other than `pages/_app.js` was made.

Global CSS cannot be used in files other than your Custom `<App>` due to its side-effects and ordering problems.

#### Possible Ways to Fix It

Relocate all Global CSS imports to your `pages/_app.js` file.
11 changes: 9 additions & 2 deletions errors/page-without-valid-component.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@

#### Why This Error Occurred

While auto exporting a page a valid React Component wasn't found. This could mean you have a file in `pages` that exports something that is not a React Component.
A page that does not export a valid React Component was found while analyzing the build output.

This is a hard error because the page would error when rendered, and causes poor build performance.

#### Possible Ways to Fix It

Move any non-page files that don't export a React Component as the default export to a different folder like `components` or `lib`.
Investigate the list of page(s) specified in the error message.
For each, you'll want to check if the file is meant to be a page.

If the file is not meant to be a page, and instead, is a shared component or file, move the file to a different folder like `components` or `lib`.

If the file is meant to be a page, double check you have an `export default` with the React Component instead of an `export`. If you're already using `export default`, make sure the returned valid is a valid React Component.
4 changes: 2 additions & 2 deletions errors/serverless-publicRuntimeConfig.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Using `publicRuntimeConfig` with `target` set to `serverless`
# Using `publicRuntimeConfig` or `serverRuntimeConfig` with `target` set to `serverless`

#### Why This Error Occurred

In the `serverless` target environment `next.config.js` is not loaded, so we don't support `publicRuntimeConfig`.
In the `serverless` target environment `next.config.js` is not loaded, so we don't support `publicRuntimeConfig` or `serverRuntimeConfig`.

#### Possible Ways to Fix It

Expand Down
38 changes: 38 additions & 0 deletions errors/static-dir-deprecated.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Static directory is deprecated

#### Why This Error Occurred

In versions prior to 9.0.6 the `static` directory was used to serve static assets in a Next.js application. This has been deprecated in favor of a `public` directory.

The reason we want to support a `public` directory instead is to not require the `/static` prefix for assets anymore and there is no reason to maintain both paths.

#### Possible Ways to Fix It

You can move your `static` directory inside of the `public` directory and all URLs will remain the same as they were before.

**Before**

```sh
static/
my-image.jpg
pages/
index.js
components/
my-image.js
```

**After**

```sh
public/
static/
my-image.jpg
pages/
index.js
components/
my-image.js
```

### Useful Links

- [Static file serving docs](https://nextjs.org/docs#static-file-serving-eg-images)
2 changes: 1 addition & 1 deletion examples/active-class-name/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example active-class-name active-class-name-app
Expand Down
3 changes: 3 additions & 0 deletions examples/amp-story/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.next
node_modules
42 changes: 42 additions & 0 deletions examples/amp-story/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Google AMP Story

## How to use

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example amp-story amp-app
# or
yarn create next-app --example amp-story amp-app
```

### Download manually

Download the example:

```bash
curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/amp-story
cd amp-story
```

Install it and run:

```bash
npm install
npm run dev
# or
yarn
yarn dev
```

Deploy it to the cloud with [now](https://zeit.co/now) ([download](https://zeit.co/download))

```bash
now
```

## The idea behind the example

This example shows how to create an AMP page with `amp-story` using Next.js and the AMP feature.
15 changes: 15 additions & 0 deletions examples/amp-story/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "amp-story",
"version": "1.0.0",
"scripts": {
"dev": "next",
"build": "next build",
"start": "next start"
},
"dependencies": {
"next": "latest",
"react": "^16.7.0",
"react-dom": "^16.7.0"
},
"license": "ISC"
}
123 changes: 123 additions & 0 deletions examples/amp-story/pages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
import Head from 'next/head'

export const config = { amp: true }

export default () => (
<>
<Head>
<title>Example AMP Story in Next.js</title>
<script
async
key='amp-story'
custom-element='amp-story'
src='https://cdn.ampproject.org/v0/amp-story-1.0.js'
/>
<script
async
key='amp-video'
custom-element='amp-video'
src='https://cdn.ampproject.org/v0/amp-video-0.1.js'
/>
</Head>

<amp-story
standalone=''
title='Stories in AMP - Hello World'
publisher='AMP Project'
publisher-logo-src='https://amp.dev/favicons/coast-228x228.png'
poster-portrait-src='https://amp.dev/static/samples/img/story_dog2_portrait.jpg'
poster-square-src='https://amp.dev/static/samples/img/story_dog2_square.jpg'
poster-landscape-src='https://amp.dev/static/samples/img/story_dog2_landscape.jpg'
>
{/* <!-- A story consists of one or more pages. Each page is declared by an `amp-story-page` element. Pages are designed by layering videos, images and text. Here we have a page that uses two layers. One layer filling the available space with an image and one text layer that shows a heading. --> */}
<amp-story-page id='page-1'>
<amp-story-grid-layer template='fill'>
<amp-img
src='https://amp.dev/static/samples/img/story_dog2.jpg'
width='720'
height='1280'
layout='responsive'
/>
</amp-story-grid-layer>
<amp-story-grid-layer template='vertical'>
<h1>Hello World</h1>
<p>This is an AMP Story.</p>
</amp-story-grid-layer>
</amp-story-page>

{/* <!-- Here we have a page consisting of a video which autoplays and loops. --> */}
<amp-story-page id='page-2'>
<amp-story-grid-layer template='fill'>
<amp-video
autoplay=''
loop=''
width='720'
height='960'
poster='https://amp.dev/static/samples/img/story_video_dog_cover.jpg'
layout='responsive'
>
<source
src='https://amp.dev/static/samples/video/story_video_dog.mp4'
type='video/mp4'
/>
</amp-video>
</amp-story-grid-layer>
</amp-story-page>

{/* <!-- Pre-defined entry animations make it possible to create dynamic pages without videos. The length and initial delay can be customized using the `animate-in-duration` and `animate-in-delay` properties. The [animations sample](/documentation/examples/visual-effects/amp_story_animations/) shows all available animantions in action. --> */}
<amp-story-page id='animation-demo'>
<amp-story-grid-layer template='fill'>
<amp-img
src='https://amp.dev/static/samples/img/story_dog4.jpg'
animate-in='fly-in-top'
width='720'
height='1280'
layout='responsive'
/>
</amp-story-grid-layer>
<amp-story-grid-layer template='thirds'>
<h2
animate-in='fly-in-bottom'
grid-area='lower-third'
animate-in-delay='0.4s'
>
Best walk ever!
</h2>
</amp-story-grid-layer>
</amp-story-page>

{/* <!-- Stories can use predefined layouts to style the page. Here we're using the `thirds` template. For an overview about the available layouts take a look at the [layouts sample](/documentation/examples/style-layout/amp_story_layouts/). --> */}
<amp-story-page id='layout-demo'>
<amp-story-grid-layer template='thirds'>
<amp-img
grid-area='upper-third'
src='https://amp.dev/static/samples/img/story_thirds_1.jpg'
width='560'
height='420'
layout='responsive'
/>
<amp-img
grid-area='middle-third'
src='https://amp.dev/static/samples/img/story_thirds_2.jpg'
width='560'
height='420'
layout='responsive'
/>
<amp-img
grid-area='lower-third'
src='https://amp.dev/static/samples/img/story_thirds_3.jpg'
width='560'
height='420'
layout='responsive'
/>
</amp-story-grid-layer>
</amp-story-page>

{/* <!-- A "bookend" panel containing links to other resources will appear on the last page of your story if you include an `amp-story-bookend` that references a [bookend JSON config](/static/samples/json/bookend.json). --> */}
<amp-story-bookend
src='https://amp.dev/static/samples/json/bookend.json'
layout='nodisplay'
/>
</amp-story>
</>
)
4 changes: 2 additions & 2 deletions examples/amp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example amp amp-app
Expand Down Expand Up @@ -39,4 +39,4 @@ now

## The idea behind the example

This example shows how to create AMP pages using Next.js and the experimental AMP feature. It shows a normal page (non-AMP), an AMP only page, and a hybrid AMP page.
This example shows how to create AMP pages using Next.js and the AMP feature. It shows a normal page (non-AMP), an AMP only page, and a hybrid AMP page.
2 changes: 1 addition & 1 deletion examples/analyze-bundles/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example analyze-bundles analyze-bundles-app
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-apollo-server-and-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example api-routes-apollo-server-and-client api-routes-apollo-server-and-client-app
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-graphql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example api-routes-graphql api-routes-graphql-app
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-micro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example api-routes-micro api-routes-micro-app
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-middleware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://github.com/segmentio/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example api-routes-middleware api-routes-middleware-app
Expand Down
2 changes: 1 addition & 1 deletion examples/api-routes-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### Using `create-next-app`

Execute [`create-next-app`](https://www.npmjs.com/package/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:
Execute [`create-next-app`](https://github.com/zeit/next.js/tree/canary/packages/create-next-app) with [Yarn](https://yarnpkg.com/lang/en/docs/cli/create/) or [npx](https://github.com/zkat/npx#readme) to bootstrap the example:

```bash
npx create-next-app --example api-routes-rest api-routes-rest-app
Expand Down
Loading

0 comments on commit a8cb017

Please sign in to comment.