-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Pooya Parsa <[email protected]>
- Loading branch information
Showing
7 changed files
with
79 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
title: Layer0 Provider | ||
description: Optimize images with Layer0's optimization service | ||
navigation: | ||
title: Layer0 | ||
--- | ||
|
||
Layer0 provides a simple HTTP service for optimizing images. | ||
|
||
:::alert{type="info"} | ||
The image optimizer will only return an optimized image for mobile browsers. Desktop browsers are served the original image. | ||
::: | ||
|
||
This integration works out of the box without need to configure! See the [Documentation](https://docs.layer0.co/guides/image_optimization) for more information. | ||
|
||
**Example:** | ||
|
||
```vue | ||
<nuxt-img provider="layer0" src="https://i.imgur.com/LFtQeX2.jpeg" width="200" height="200" quality="80" /> | ||
``` | ||
|
||
## Modifiers | ||
|
||
Layer0 supports the following modifiers: `height`, `width` and `quality` | ||
|
||
## Options | ||
|
||
### `baseURL` | ||
|
||
- Defalt: `https://opt.moovweb.net` |
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 |
---|---|---|
|
@@ -15,6 +15,7 @@ const BuiltInProviders = [ | |
'imgix', | ||
'ipx', | ||
'netlify', | ||
'layer0', | ||
'prismic', | ||
'sanity', | ||
'static', | ||
|
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,24 @@ | ||
import { joinURL } from 'ufo' | ||
import type { ProviderGetImage } from 'src' | ||
import { createOperationsGenerator } from '~image' | ||
|
||
const operationsGenerator = createOperationsGenerator({ | ||
keyMap: { | ||
height: 'height', | ||
quality: 'quality', | ||
width: 'width' | ||
}, | ||
joinWith: '&', | ||
formatter: (key, value) => String(value) === 'true' ? key : `${key}=${value}` | ||
}) | ||
|
||
export const getImage: ProviderGetImage = (src, { | ||
modifiers = {}, | ||
baseURL = 'https://opt.moovweb.net' | ||
} = {}) => { | ||
const operations = operationsGenerator(modifiers) | ||
|
||
return { | ||
url: joinURL(baseURL, '?img=' + src + (operations ? ('&' + operations) : '')) | ||
} | ||
} |
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