-
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.
- Loading branch information
1 parent
d837956
commit 231900b
Showing
8 changed files
with
104 additions
and
0 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,19 @@ | ||
--- | ||
title: Directus | ||
description: Nuxt Image has first class integration with Directus | ||
--- | ||
|
||
Integration between [Directus](https://docs.directus.io/reference/files/#requesting-a-thumbnail) and the image module. | ||
|
||
To use this provider you need to specify the base url of your service in Directus. | ||
|
||
```js{}[nuxt.config.js] | ||
export default { | ||
image: { | ||
directus: { | ||
// baseURL of your Directus application | ||
baseURL: 'https://demo.directus.io' | ||
} | ||
} | ||
} | ||
``` |
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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// https://docs.directus.io/reference/files/#requesting-a-thumbnail | ||
|
||
import { joinURL, encodeQueryItem, encodePath, withBase } from 'ufo' | ||
import { ProviderGetImage } from 'src' | ||
import { createOperationsGenerator } from '~image' | ||
|
||
const operationsGenerator = createOperationsGenerator({ | ||
keyMap: { | ||
width: 'width', | ||
height: 'height', | ||
fit: 'fit', | ||
format: 'format', | ||
quality: 'quality', | ||
withoutEnlargement: 'withoutEnlargement', | ||
transforms: 'transforms' | ||
}, | ||
valueMap: { | ||
fit: { | ||
inside: 'inside', | ||
outside: 'outside', | ||
cover: 'cover', | ||
contain: 'contain' | ||
}, | ||
format: { | ||
jpeg: 'jpg' | ||
} | ||
}, | ||
joinWith: '&', | ||
formatter: (key, val) => encodeQueryItem(key, val) | ||
}) | ||
|
||
export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = '/' } = {}) => { | ||
const params = operationsGenerator(modifiers) | ||
|
||
return { | ||
url: withBase(joinURL('/assets/', encodePath(src) + (params ? '?' + params : '')), baseURL) | ||
} | ||
} |
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