Skip to content

Commit

Permalink
feat: implement buildUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
frederickfogerty committed Apr 17, 2020
1 parent 6ebd3de commit b1693ba
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/plugins/vue-imgix/vue-imgix.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import ImgixClient from 'imgix-core-js';
import {
IBuildUrl,
IBuildUrlObject,
IBuildUrlObjectResult,
IImgixClientOptions,
IImgixParams,
IVueImgixClient,
} from './types';

Expand All @@ -19,12 +21,16 @@ class VueImgixClient implements IVueImgixClient {
(this.client as any).settings.libraryParam = `vue-${VERSION}`;
}

buildUrlObject(url: string, options?: {}): IBuildUrlObjectResult {
buildUrlObject(url: string, options?: IImgixParams): IBuildUrlObjectResult {
const src = this.client.buildURL(url, options);
const srcset = this.client.buildSrcSet(url, options);

return { src, srcset };
}

buildUrl(url: string, options?: IImgixParams): string {
return this.client.buildURL(url, options);
}
}

export const buildImgixClient = (options: IImgixClientOptions) => {
Expand Down Expand Up @@ -55,4 +61,9 @@ export const buildUrlObject: IBuildUrlObject = (...args) => {
return client.buildUrlObject(...args);
};

export const buildUrl: IBuildUrl = (...args) => {
const client = ensureVueImgixClientSingleton();
return client.buildUrl(...args);
};

export { IVueImgixClient };

0 comments on commit b1693ba

Please sign in to comment.