Merge pull request #687 from timlrx/docs/static-build
add code sample for image.tsx
This commit is contained in:
commit
af33eb2b8e
16
README.md
16
README.md
@ -232,7 +232,21 @@ See [Next.js on Netlify](https://docs.netlify.com/integrations/frameworks/next-j
|
||||
|
||||
1. Add `output: 'export'` in `next.config.js`. See [static exports documentation](https://nextjs.org/docs/app/building-your-application/deploying/static-exports#configuration) for more information.
|
||||
2. Comment out `headers()` from `next.config.js`.
|
||||
3. Change `components/Image.tsx` to use a standard `<img>` tag instead of `next/image`. Alternatively, to continue using `next/image`, you can use an alternative image optimization provider such as Imgix, Cloudinary or Akamai. See [image optimization documentation](https://nextjs.org/docs/app/building-your-application/deploying/static-exports#image-optimization) for more details.
|
||||
3. Change `components/Image.tsx` to use a standard `<img>` tag instead of `next/image`:
|
||||
|
||||
```ts
|
||||
/* eslint-disable jsx-a11y/alt-text */
|
||||
/* eslint-disable @next/next/no-img-element */
|
||||
import NextImage, { ImageProps } from 'next/image'
|
||||
|
||||
// @ts-ignore
|
||||
const Image = ({ ...rest }: ImageProps) => <img {...rest} />
|
||||
|
||||
export default Image
|
||||
```
|
||||
|
||||
Alternatively, to continue using `next/image`, you can use an alternative image optimization provider such as Imgix, Cloudinary or Akamai. See [image optimization documentation](https://nextjs.org/docs/app/building-your-application/deploying/static-exports#image-optimization) for more details.
|
||||
|
||||
4. Remove `api` folder and components which call the server-side function such as the Newsletter component. Not technically required and the site will build successfully, but the APIs cannot be used as they are server-side functions.
|
||||
5. Run `yarn build`. The generated static content is in the `out` folder.
|
||||
6. Deploy the `out` folder to your hosting service of choice or run `npx serve out` to view the website locally.
|
||||
|
Loading…
x
Reference in New Issue
Block a user