Skip to content

Commit c7808d8

Browse files
committed
add example project & readme adjustments
1 parent d29917e commit c7808d8

File tree

15 files changed

+1926
-41
lines changed

15 files changed

+1926
-41
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</div>
66

77
<div align="center">
8-
<a href="https://www.npmjs.com/package/next-image-proxy"><img alt="npm version badge" src="https://img.shields.io/npm/v/next-image-proxy"></a>
9-
<img alt="license badge" src="https://img.shields.io/npm/l/next-image-proxy">
8+
<a href="https://www.npmjs.com/package/@blazity/next-image-proxy"><img alt="npm version badge" src="https://img.shields.io/npm/v/@blazity/next-image-proxy"></a>
9+
<img alt="license badge" src="https://img.shields.io/npm/l/@blazity/next-image-proxy">
1010
</div>
1111

1212
<br />
@@ -25,11 +25,11 @@ You have to remember that there're some cons:
2525
## 🧰 Installation
2626

2727
```
28-
$ npm i --save next-image-proxy
28+
$ npm i --save @blazity/next-image-proxy
2929
3030
# or
3131
32-
$ yarn add next-image-proxy
32+
$ yarn add @blazity/next-image-proxy
3333
```
3434

3535
## 💻 Use
@@ -39,20 +39,21 @@ It is really simple to setup, you just need to add a new API route that exports
3939
```tsx
4040
// pages/api/imageProxy.ts
4141

42-
import { withImageProxy } from 'next-image-proxy'
42+
import { withImageProxy } from '@blazity/next-image-proxy'
4343

44-
export default withImageProxy({ whitelistedPatterns: [/medium.com/] })
44+
export default withImageProxy({ whitelistedPatterns: [/^https?:\/\/(.*).medium.com/] })
4545
```
4646

4747
and now you prefix the image you want to use:
4848

4949
```tsx
5050
import NextImage from 'next/image'
5151

52-
{
53-
/* O.F.C. */
52+
export function SomeComponent() {
53+
const actualImageUrl = 'https://cdn-images-1.medium.com/max/1024/1*xYoAR2XRmoCmC9SONuTb-Q.png'
54+
55+
return <NextImage src={`/api/imageProxy?imageUrl=${actualImageUrl}`} width={700} height={300} />
5456
}
55-
return <NextImage src={`api/imageProxy?imageUrl=${originalUrl}`} />
5657
```
5758

5859
## 🤲🏻 Contributing

example/.eslintrc.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

example/.gitignore

Lines changed: 34 additions & 0 deletions
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

example/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.js`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.js`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

example/next-env.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

example/next.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
reactStrictMode: true,
3+
}

example/package.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "example",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"@blazity/next-image-proxy": "1.0.1",
13+
"next": "12.1.0",
14+
"react": "17.0.2",
15+
"react-dom": "17.0.2"
16+
},
17+
"devDependencies": {
18+
"eslint": "8.10.0",
19+
"eslint-config-next": "12.1.0"
20+
}
21+
}

example/pages/api/imageProxy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { withImageProxy } from '@blazity/next-image-proxy'
2+
3+
export default withImageProxy({ whitelistedPatterns: [/^https?:\/\/(.*).medium.com/] })

example/pages/index.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import NextImage from 'next/image'
2+
3+
export default function Homepage() {
4+
return (
5+
<>
6+
<NextImage
7+
src="/api/imageProxy?imageUrl=https://cdn-images-1.medium.com/max/1024/1*xYoAR2XRmoCmC9SONuTb-Q.png"
8+
width={700}
9+
height={300}
10+
/>
11+
<NextImage
12+
src="/api/imageProxy?imageUrl=https://cdn-images-1.medium.com/max/300/1*TOh1Ybtg_AmyvhA9Dgc65Q.png"
13+
width={700}
14+
height={300}
15+
/>
16+
<NextImage
17+
src="/api/imageProxy?imageUrl=https://cdn-images-1.medium.com/max/287/1*ObtObJyNveLZtKF4eTgeLw.png"
18+
width={700}
19+
height={300}
20+
/>
21+
</>
22+
)
23+
}

example/public/favicon.ico

25.3 KB
Binary file not shown.

0 commit comments

Comments
 (0)