Skip to content

Commit

Permalink
feat(storyblok): update to the new service (#497)
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemartins-uon committed Jun 21, 2022
1 parent 7942232 commit 3edbd22
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/content/en/4.providers/storyblok.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Integration between [Storyblok](https://www.storyblok.com/docs/image-service/) a
export default {
image: {
storyblok: {
baseURL: 'https://img2.storyblok.com'
baseURL: 'https://a.storyblok.com'
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion playground/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default <NuxtConfig> {
baseURL: 'https://demo.twic.pics/'
},
storyblok: {
baseURL: 'https://img2.storyblok.com/'
baseURL: 'https://a.storyblok.com/'
},
cloudinary: {
baseURL: 'https://res.cloudinary.com/nuxt/image/upload/'
Expand Down
7 changes: 4 additions & 3 deletions src/runtime/providers/storyblok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withBase, joinURL, parseURL } from 'ufo'
import type { ProviderGetImage } from 'src'

// https://www.storyblok.com/docs/image-service
const storyblockCDN = 'https://img2.storyblok.com'
const storyblockCDN = 'https://a.storyblok.com'

export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = storyblockCDN } = {}) => {
const {
Expand Down Expand Up @@ -34,10 +34,11 @@ export const getImage: ProviderGetImage = (src, { modifiers = {}, baseURL = stor
_filters ? ('filters:' + _filters) : ''
)

// TODO: check if hostname is https://a.storyblok.com ?
const { pathname } = parseURL(src)

const url = withBase(joinURL(options, pathname), baseURL)
const modifier = options ? '/m/' : ''

const url = withBase(joinURL(pathname, modifier, options), baseURL)

return {
url
Expand Down

0 comments on commit 3edbd22

Please sign in to comment.