0.1.3 • Published 2 years ago

@thumbsmith/url v0.1.3

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

@thumbsmith/url

Small utility to help with constructing thumbsmith thumbnail URLs

Installation

npm install @thumbsmith/url

Usage

import getImageUrl from "@thumbsmith/url";

const imageUrl = getImageUrl({
  account: "my-account-name",
  template: "product",
  type: "png", // Optional
  data: {
    title: "Hello world!",
    breadcrumb: ["Products", "Sports", "Bikes"],
    price: 49.99,
  },
});

console.log(imageUrl);
// Result:
// https://cdn.thumbsmith.com/v1/u/my-user-name/product.png?title=Hello%20world%21&breadcrumb%5B0%5D=Products&breadcrumb%5B1%5D=Sports&breadcrumb%5B2%5D=Bikes&price=49.99

Typescript

import getImageUrl from "@thumbsmith/url";

interface ImageProps {
  title: string;
  breadcrumb: string[];
  price: number;
}

const imageUrl = getImageUrl<ImageProps>({
  account: "my-account-name",
  template: "product",
  type: "png", // Optional
  data: {
    title: "Hello world!",
    breadcrumb: ["Products", "Sports", "Bikes"],
    price: 49.99,

    // This line will cause an error
    foo: "bar",
  },
});

See the use a template page for more info.

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago